Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
AltNature 169
4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.)

Ad

Answer this question