Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

`TextButton` stops functioning after the `player` respawns?

Hello! I keep running into the issue of GUI's stopping normal function after the player resets. At initial test it works but after resetting it fails to recognize my click. Additionally, I have a sound in SoundService that definitely makes a sound out of testing but not in testing. My main issue is the GUI, not the sound but it would help if I could solve both problems so I will be posting both the OnServerEvent ServerScript and GUI script.

-------------------------- GUI SCRIPT WITH FIRE SERVER AS WELL -----------------------------

local player = game.Players.LocalPlayer
local gui = player.PlayerGui:WaitForChild("StartMenu")

local playbutton = gui.Frame.Play
local changeteambutton = gui.Frame2.Team
local frame1 = gui.Frame
local frame2 = gui.Frame2


function fire()
	 game.ReplicatedStorage.sound:FireServer()
end



	function loop(button, frame, frame2, button2)

		for i = 0, 1, .1 do
		button.Transparency = i
		frame.Transparency = 1
		wait()
	end end

playbutton.MouseButton1Click:Connect(function()
    fire()
    loop(playbutton, frame1, frame2, changeteambutton)
end)

changeteambutton.MouseButton1Click:Connect(function()
	
end)

-------------------------------- SERVER SCRIPT WITH ON SERVER EVENT ----------------------

game.ReplicatedStorage.sound.OnServerEvent:Connect(function()
	
	local sound = game:GetService("SoundService").Click_Gui
	sound:Play()
	print'sound played'
	
end)

I hope this is enough information for the reader to comprehend my issue, if additional info is necessary for a solution i will happily provide such, THANKS!

1 answer

You could do a humanoid.Died Event I think, so you could possibly detect if Humanoid.Died() and if so, disable the script (Disable is a property in script which stops it.)

This discussion is preserved as it was. New answers, comments, and votes are closed.