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

How do I edit this script function on respawn as well, as opposed to on entry only?

Asked by 4 years ago

Hey SH, I'm editing a script for group use, the game has multiple teams with the same team color (not my choice but eh), the teams are different groups so I'd like to additionally make it so that the script functions on death/respawn as well as on entry. It works right when you first load in, it doesn't work after subsequent respawns.

Here's the script down below, what do I need to change for this to work? Thank you!

local groupId = 946493

function RegisterPlayer( player ) 
if CheckInGroup(player, groupId) then 
HoldThreadForCharacter(player) 
player.Character:MoveTo(script.Parent.Position + Vector3.new(0,3,0)) 
end 
end 

function CheckInGroup( player, id ) 
if player:IsInGroup(id) then 
return true 
end 
return false 
end 

function HoldThreadForCharacter( player ) 
repeat wait() until Workspace:FindFirstChild(player.Name) 
end 

Game.Players.PlayerAdded:connect(RegisterPlayer) 
for i,v in pairs(Game.Players:GetPlayers()) do 
RegisterPlayer(v) 
end 

0
use player.CharacterAdded Reset935681 5 — 4y
0
Hey, thank you for the response. What line(s) would I edit with? WHOMATEY98765 0 — 4y

Answer this question