In my game I want to add this script and then destroy it and readd it but when I do so it no longer works so is there a way for this to activate when the player respawns??
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(function(Ch) local g = script.Arm1:clone() g.Parent = Ch local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Ch["Left Arm"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0.4, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" then h[i].Anchored = false h[i].CanCollide = false end end end) end)
Loop through the players at the start of the script, so re-adding it won't will still work.
local function characterAdded(Ch) local g = script.Arm1:clone() g.Parent = Ch local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Ch["Left Arm"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0.4, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" then h[i].Anchored = false h[i].CanCollide = false end end end for _,plr in next, game.Players:GetChildren() do plr.CharacterAdded:Connect(characterAdded) end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(characterAdded) end)
NOTE: You should probably not delete the script and re-add it.
So if you are adding the script after deleting it, the reason why your script isn't working makes sense.
For the CharacterAdded event to work, you must get a Player first. When your script is first ran, the Player is obtained through the PlayerAdded event, but once that script is deleted and added again, the PlayerAdded event is not ran because the Player is already in the game, which will result in the code not being ran.
My only suggestion is to find a way to run this script without deleting it every time.