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

How can I make this function connect every time the player dies and not just the first time?

Asked by 6 years ago
local lp = game.Players.LocalPlayer
local character = lp.Character or lp.CharacterAdded:wait()
character:WaitForChild("Humanoid").Died:Connect(function()
    print("player died")
    local frame = lp:WaitForChild("PlayerGui").WastedGui.TweenedFrame
    frame:TweenPosition(UDim2.new({0, 0},{.5, -75}), 'Out', 'Quad', 1)
    wait(4)
    frame:TweenPosition(UDim2.new({0, 0},{-1, -75}), 'Out', 'Quad', 1)
end)

this script only works the first time the player dies.

0
Where is the script located? Also, don't use curly brackets in your UDim2.new() Azarth 3141 — 6y
0
It's located in StarterGui.WastedGui.TweenedFrame.Wasted.LocalScript creeperhunter76 554 — 6y
1
Did you turn off the "ResetOnSpawn" bool on the ScreenGui? You also don't need to reference PlayerGui, just use Parents. Azarth 3141 — 6y
0
ResetOnSpawn is enabled, do I turn it off? creeperhunter76 554 — 6y
View all comments (4 more)
0
No, it should be checked. What does the output say? Apart from the curly brackets and maybe your frame variable pointing to the wrong location, it works fine. Azarth 3141 — 6y
0
GUI only appears on the first death still, script only prints "player died" in the output the first time as well (fixed the curly bracket and used script.Parent.Parent for frame) creeperhunter76 554 — 6y
0
Why don't you add a line between 2 &3, and put 'character:WaitForChild("Humanoid")', then on line 3, which is now 4, try 'character.Humanoid.Died:Connect(function()' thesit123 509 — 6y
0
Same result. creeperhunter76 554 — 6y

Answer this question