69 lines
3.0 KiB
Luau
69 lines
3.0 KiB
Luau
-- BenchPressClient (LocalScript, StarterPlayer.StarterPlayerScripts) — client side of the bench press:
|
|
-- a jump gets up from the bench, the default Animate script pauses while pressing (the server moves the body),
|
|
-- the camera holds still on the body, and the rest timer (attribute BenchRestUntil, set by the server) is shown.
|
|
-- No limits are checked here — only display.
|
|
local Players = game:GetService("Players")
|
|
local UserInputService = game:GetService("UserInputService")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
local player = Players.LocalPlayer
|
|
local remote = ReplicatedStorage:WaitForChild("OrnamentMachine"):WaitForChild("BenchPress")
|
|
|
|
UserInputService.JumpRequest:Connect(function()
|
|
if player:GetAttribute("BenchPressing") then remote:FireServer("Stop") end
|
|
end)
|
|
|
|
player:GetAttributeChangedSignal("BenchPressing"):Connect(function()
|
|
local ch = player.Character
|
|
if not ch then return end
|
|
local on = player:GetAttribute("BenchPressing") == true
|
|
local hum = ch:FindFirstChildOfClass("Humanoid")
|
|
local hrp = ch:FindFirstChild("HumanoidRootPart")
|
|
local cam = workspace.CurrentCamera
|
|
if on and hrp then cam.CameraSubject = hrp elseif hum then cam.CameraSubject = hum end
|
|
local animate = ch:FindFirstChild("Animate")
|
|
if animate and animate:IsA("LocalScript") then animate.Enabled = not on end
|
|
local animator = hum and hum:FindFirstChildOfClass("Animator")
|
|
if on and animator then
|
|
for _, t in animator:GetPlayingAnimationTracks() do t:Stop(0.1) end
|
|
end
|
|
end)
|
|
|
|
-- rest timer
|
|
local gui = Instance.new("ScreenGui")
|
|
gui.Name = "BenchRestTimer"
|
|
gui.ResetOnSpawn = false
|
|
gui.Enabled = false
|
|
local label = Instance.new("TextLabel")
|
|
label.AnchorPoint = Vector2.new(0.5, 0)
|
|
label.Position = UDim2.new(0.5, 0, 0, 70)
|
|
label.Size = UDim2.fromOffset(240, 34)
|
|
label.BackgroundColor3 = Color3.fromRGB(16, 24, 48)
|
|
label.BackgroundTransparency = 0.15
|
|
label.TextColor3 = Color3.fromRGB(255, 220, 140)
|
|
label.Font = Enum.Font.GothamBold
|
|
label.TextScaled = true
|
|
local c = Instance.new("UICorner"); c.CornerRadius = UDim.new(0, 10); c.Parent = label
|
|
local st = Instance.new("UIStroke"); st.Color = Color3.fromRGB(255, 200, 90); st.Thickness = 2; st.ApplyStrokeMode = Enum.ApplyStrokeMode.Border; st.Parent = label
|
|
label.Parent = gui
|
|
gui.Parent = player:WaitForChild("PlayerGui")
|
|
|
|
-- shown for 3 s only when the bench prompt is pressed during the rest
|
|
local showToken = 0
|
|
game:GetService("ProximityPromptService").PromptTriggered:Connect(function(prompt)
|
|
if prompt.Name ~= "BenchPrompt" then return end
|
|
local t = player:GetAttribute("BenchRestUntil")
|
|
if type(t) ~= "number" or t <= workspace:GetServerTimeNow() then return end
|
|
showToken += 1
|
|
local my = showToken
|
|
local stopAt = os.clock() + 3
|
|
gui.Enabled = true
|
|
while my == showToken and os.clock() < stopAt do
|
|
local s = math.ceil(t - workspace:GetServerTimeNow())
|
|
if s <= 0 then break end
|
|
label.Text = "Barbell rest: " .. math.floor(s / 60) .. ":" .. string.format("%02d", s % 60)
|
|
task.wait(0.25)
|
|
end
|
|
if my == showToken then gui.Enabled = false end
|
|
end)
|