So the script works fine until the player resets and respawns. Whenever I click on the button, it doesn't do anything anymore.
This is a LocalScript located within: TextBox>Frame>ScreenGui>StarterGui
playerChar = game:GetService("Players").LocalPlayer.Character
playerHumanoid = playerChar:WaitForChild("Humanoid")
checkValue = game:GetService("ReplicatedStorage").Values.animIsPlaying
running = game:GetService("ReplicatedStorage").Values.isRunning
-- Animations
local sitAnim = Instance.new("Animation")
sitAnim.AnimationId = "rbxassetid://03225667771"
local sittingAnim = Instance.new("Animation")
sittingAnim.AnimationId = "rbxassetid://03225675930"
-- Animation tracks
local sitTrack = playerHumanoid:LoadAnimation(sitAnim)
local sittingTrack = playerHumanoid:LoadAnimation(sittingAnim)
UIS = game:GetService("UserInputService")
debounce = false
check = 0
script.Parent.MouseButton1Click:connect(function()
if check == 0 and checkValue.Value == false and running.Value == false and playerHumanoid then
print("Working!")
playerHumanoid.WalkSpeed = 0
sitTrack:Play()
wait(0.1)
sittingTrack:Play()
playerHumanoid.WalkSpeed = 0
check = 1
checkValue.Value = true
elseif check == 1 and checkValue.Value == true then
sittingTrack:Stop()
playerHumanoid.WalkSpeed = 16
check = 0
checkValue.Value = false
end
wait(1.5)
debounce = false
end)
