Gui Button stops working after player respawn

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    For buttons to continue working after player respawns.
  2. What is the issue? Include screenshots / videos if possible!
    After player respawns, I get the following error upon button click
    Cannot load the AnimationClipProvider Service. - Client - Mobile:16
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried applying similar codes from other working buttons but have failed.

I would like to point out, this is a big issue within the game. I would be more than happy to provide a payout if someone helps me solve issue.

Thanks in advance for your help!

script under button


local Event = game.ReplicatedStorage:WaitForChild("dofacENC")
local Cool = false
local plr = game.Players.LocalPlayer
local Char = plr.Character  or plr.CharacterAdded:Wait()

---- Animation
Animation = game.Lighting.Anim.dofac
----  Cooldown
local Cooldown = 10

script.Parent.MouseButton1Click:Connect(function()
	if Cool == false then
		Cool = true
		Event:FireServer()
		local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
		LoadAnimation:Play()
		
		Cool = true
		Event:FireServer()
		-- timer part starts here add after fireserver event
		for i = Cooldown,1,-1 do --Loop counting down from 15 to 1 (CHANGE "cooldown to a number unless using a local function")
			script.Parent.Text = i --Display the number of the loop
			wait(1) --Wait 1 second before the next iteration
			script.Parent.Text = script.Parent.Name
		end -- timer part ends here
 		wait(0.5)
		--plr.PlayerGui.Quirk.skill.C.Text = "C"
		Cool = false		
	end
end)

Humanoid:LoadAnimation() is deprecated.

Maybe my idea is to use function and load animation using pcall, if not success, it will fire function again with wait() until it works.

correct, I checked, and it is disabled

just do Player.CharacterAdded:Connect(function()
and rerun the script
)

local Event = game.ReplicatedStorage:WaitForChild("dofacENC")
local Cool = false
local plr = game.Players.LocalPlayer
local Char = plr.Character  or plr.CharacterAdded:Wait()

---- Animation
Animation = game.Lighting.Anim.dofac
----  Cooldown
local Cooldown = 10
plr.CharacterAdded:Connect(function(character)
  script.Parent.MouseButton1Click:Connect(function()
	if Cool == false then
		Cool = true
		Event:FireServer()
		local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
		LoadAnimation:Play()
		
		Cool = true
		Event:FireServer()
		-- timer part starts here add after fireserver event
		for i = Cooldown,1,-1 do --Loop counting down from 15 to 1 (CHANGE "cooldown to a number unless using a local function")
			script.Parent.Text = i --Display the number of the loop
			task.wait(1) --Wait 1 second before the next iteration
			script.Parent.Text = script.Parent.Name
		end -- timer part ends here
        task.wait(0.5)
		--plr.PlayerGui.Quirk.skill.C.Text = "C"
		Cool = false		
	end
end)  
end)

Tried both ideas. I get no errors with this code but doesn’t do anything.

I would like to point out, this is a big issue within the game. I would be more than happy to provide a payout if someone helps me solve issue.

Charoite: Would you mind fixing the script applying your idea? maybe I’m doing it wrong. Please & thank you!

When you respawn, please check whether the script is disabled. If it is not disabled, then add printings:

script.Parent.MouseButton1Click:Connect(function()
        print("clicked")
	if Cool == false then
                print("functional")
		Cool = true
		Event:FireServer()
		local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
		LoadAnimation:Play()
		
		Cool = true
		Event:FireServer()
		-- timer part starts here add after fireserver event
		for i = Cooldown,1,-1 do --Loop counting down from 15 to 1 (CHANGE "cooldown to a number unless using a local function")
			script.Parent.Text = i --Display the number of the loop
			wait(1) --Wait 1 second before the next iteration
			script.Parent.Text = script.Parent.Name
		end -- timer part ends here
 		wait(0.5)
		--plr.PlayerGui.Quirk.skill.C.Text = "C"
		Cool = false		
	end
end)

If it prints “clicked” but not “functional”, then probably there is something which is affecting the script or the debounce isn’t working. Always do debugging/fixing with printings, it is helpful!

Appreciate the tip! So it does not disable and does print “clicked” & not functional.

“functional” isn’t being printed. It indicates that the “Cool” debounce is not false.
Does the button works multiple times when you don’t respawn?

Correct, it works multiple times up until respawn.

Try to do this

script.Parent.MouseButton1Click:Connect(function()
    print("clicked")
    print(Cool)
	if Cool == false then
        print("functional")
		Cool = true
		Event:FireServer()
		local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
		LoadAnimation:Play()
		
		Cool = true
		Event:FireServer()
		-- timer part starts here add after fireserver event
		for i = Cooldown,1,-1 do --Loop counting down from 15 to 1 (CHANGE "cooldown to a number unless using a local function")
			script.Parent.Text = i --Display the number of the loop
			wait(1) --Wait 1 second before the next iteration
			script.Parent.Text = script.Parent.Name
		end -- timer part ends here
 		wait(0.5)
		--plr.PlayerGui.Quirk.skill.C.Text = "C"
		Cool = false
        else
            print(Cool)		
	end
end)

Continues to do same error :/. Before respawn it does print functional as normal.

Oops. What I meant is test it after respawning.

Error? Can you show us the error printed in output?

Yes, this is before respawn:

 22:37:24.451  clicked  -  Client - Mobile:13
  22:37:24.451  false  -  Client - Mobile:14
  22:37:24.451  functional  -  Client - Mobile:16

this is after respawn:

  clicked  -  Client - Mobile:13
  22:35:26.736  true  -  Client - Mobile:14
  22:35:26.736  true  -  Client - Mobile:34
  22:35:27.621  clicked  -  Client - Mobile:13
  22:35:27.622  true  -  Client - Mobile:14
  22:35:27.622  true  -  Client - Mobile:34

I would like to point out that the keycode (in this case “C” on Keyboard) always works fine. its the screen button that stops functioning. Would context action service work somehow?

Does the “C” detecting script and this “Mobile” script under the same Screengui?

1 Like

No, the C keycode script is in ServerScriptService

Try to go the screen gui and disable/enable “Reset On Spawn” property

2 Likes