I’m having a bit of trouble with my script. My knowledge is extremely limited, so I’m doing the best that I can with what I know but I can’t, for the life of me, seem to resolve the issue with this script. I’ve tried inserting print statements all over to pinpoint it but those efforts also failed me.
Basically, this script is supposed to clone a gui from ServerStorage and display it to the player if they don’t already have it. I can post the code from the LocalScript in the gui if necessary, but all it really does is play a sound, fade away, then delete itself via Destroy().
The script runs fine the first time. The gui is cloned and the player is teleported (essentially to prevent the script from running over and over again), but after the gui destroys itself, FindFirstChild() seems to think it still thinks it exists, causing the block associated with it not to run the second time.
Here’s the code:
Players = game:GetService("Players") ServerStorage = game:GetService("ServerStorage") Part = script.Parent scriptDebounce = Part.scriptDebounce Part.Touched:Connect(function(touchedBy) local Character = touchedBy.Parent local Humanoid = Character:FindFirstChild("Humanoid") local Player = Players:GetPlayerFromCharacter(Character) if scriptDebounce.Value == true then if Player ~= nil then scriptDebounce.Value = false if Player.PlayerGui:FindFirstChild("SoundGui") == nil then local SoundGui = ServerStorage.Guis.SoundGui:Clone() SoundGui.Parent = Player.PlayerGui end if Humanoid ~= nil then Humanoid.Torso.CFrame = CFrame.new(Part.Position.X + 6, Part.Position.Y, Part.Position.Z) end scriptDebounce.Value = true end end end)
Any assistance would be greatly appreciated. I’ve done a little searching on Google and the Developer Forum in an attempt to find a solution but I think we both can conclude I wasn’t able to figure it out. Many thanks!