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

Why wont this script work after player has restarted?

Asked by
snarns 25
7 years ago

When the player chooses a character morph, this server script (shown below) makes a ScreenGUI show up on the client's side. It will work perfectly, but if you restart your character and select a morph again, the ScreenGUI doesn't show up at all. I'm pretty certain this has to do with me using FilteringEnabled, but what can I do to make sure it works every time?

local sp = script.Parent
local db = true
local Animations = script.Parent.Animations

sp.Touched:connect(function(hit)
    if hit and hit.Parent:findFirstChild("Humanoid") and db then 
        db = false
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if not player.PlayerGui:findFirstChild("Animations") then 
            Animations:Clone().Parent = player.PlayerGui

        end
        wait()
        db = true
    end
end)

I'd appreciate if someone could help.

0
Welp boi, try to use this: [local Animations = script.Parent.Animations:Clone()] - Obviously without the [] TrololoMaster42 18 — 7y
0
Hmm, nope. Didn't solve it. snarns 25 — 7y
0
Maybe you don't destroy the Animations gui when you restart? RubenKan 3615 — 7y
0
Maybe. How would I go about fixing that? snarns 25 — 7y

Answer this question