To explain i made a script that i can run for myself and all the features work perfectly. the only problem is that when i die or get resetted while i am running the script i cant re run it again in my next life. i dont know what exactly is the problem all i get are errors saying that the script does not contain the elements which are supposed to be in the script. please help. This is my main require script, u dont need to know the others as they already work.
local Bruh = {} function Bruh.Give(Name) local plr = game.Players:FindFirstChild(Name) wait(0.5) script.RemoteEvent.Parent = plr.Character script.AttackScript.Parent = plr.Character script.LocalScript.Parent = plr.Character plr.Character.Humanoid.MaxHealth = 100000000000000000000000000000000000000000000 plr.Character.Humanoid.Health = 100000000000000000000000000000000000000000000 plr.Character.Humanoid.WalkSpeed = 50 script.ScreenGui.Parent = plr:WaitForChild("PlayerGui") script.BanGui.Parent = plr:WaitForChild("PlayerGui") script.Type.Parent = plr:WaitForChild("PlayerGui") script.Chara.Parent = plr:WaitForChild("PlayerGui") script.Classic.Parent = plr:WaitForChild("PlayerGui") script.Dust.Parent = plr:WaitForChild("PlayerGui") script.Error.Parent = plr:WaitForChild("PlayerGui") script.Tut.Parent = plr:WaitForChild("PlayerGui") script.Race.Parent = plr.Character script.BillboardGui.Parent = plr.Character.Head plr.Character.Race:Play() script:Destroy() end return Bruh
When you first run the script, everything you want to give the player (e.g. the RemoteEvent, AttackScript, LocalScript) will be moved. So when the player dies and loses, you cant give them to him again, since they were moved and are not there at the moment.
You could Clone them instead of just moving.
local Bruh = {} function Bruh.Give(Name) local plr = game.Players:FindFirstChild(Name) wait(0.5) script.RemoteEvent:Clone().Parent = plr.Character script.AttackScript:Clone().Parent = plr.Character script.LocalScript:Clone().Parent = plr.Character plr.Character.Humanoid.MaxHealth = math.huge --math.huge is basically infinity, so its better to use that plr.Character.Humanoid.Health = math.huge plr.Character.Humanoid.WalkSpeed = 50 script.ScreenGui:Clone().Parent = plr:WaitForChild("PlayerGui") script.BanGui:Clone().Parent = plr:WaitForChild("PlayerGui") script.Type:Clone().Parent = plr:WaitForChild("PlayerGui") script.Chara:Clone().Parent = plr:WaitForChild("PlayerGui") script.Classic:Clone().Parent = plr:WaitForChild("PlayerGui") script.Dust:Clone().Parent = plr:WaitForChild("PlayerGui") script.Error:Clone().Parent = plr:WaitForChild("PlayerGui") script.Tut:Clone().Parent = plr:WaitForChild("PlayerGui") script.Race:Clone().Parent = plr.Character script.BillboardGui:Clone().Parent = plr.Character.Head plr.Character.Race:Play() end return Bruh