I made this Script in a Part which works fine! Here is the Script:
script.Parent.Touched:Connect(function(hit) local Player = game:GetService("Players"):FindFirstChild(hit.Parent.Name) local PlayerGui = Player.PlayerGui local RebirthButton = PlayerGui:WaitForChild("RebirthUi").TextButton local TextButton = PlayerGui:WaitForChild("RebirthUi").TextLabel if RebirthButton.Visible == false then TextButton.Visible = true RebirthButton.Visible = true PlayerGui:WaitForChild("RebirthUi").RebirthAmount.Value = script.Parent.Amount.Value Player:WaitForChild("leaderstats").RebirthAmount.Value = script.Parent.Amount.Value wait(5) else TextButton.Visible = false RebirthButton.Visible = false wait(5) end end)
The Script is in a Part in Workspace. MY FIRST PROBLEM is that when the Gui closes this error in output appears but it still works… Workspace.Rebirth.Script:3: attempt to index nil with ‘WaitForChild’
THE SECOND THING is that I was wondering if I could make a local script to handle the parts (I have exact the same parts in Workspace but they all have different Values… the first problem is that I don’t know how to handle multiple parts with one script and the second problem is that the Values would get changed by the client… Any help would be appreciated!!!