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

How can I make this script so that when a player re-spawns it runs?

Asked by 10 years ago

Here's the code :

names = {"Alpha","Bravo","James","Kilo","Papa","Zulu","November","Yankee"}

function handout()
for i,v in pairs(game.Players:GetChildren()) do
if workspace:FindFirstChild(v.Name) then
c = BrickColor.Random()
local b = Instance.new("BillboardGui",workspace[v.Name].Head)
b.Size =UDim2.new(6,0,2,0) b.StudsOffset = Vector3.new(0,1.5,0)
local text = Instance.new("TextLabel",b) text.Size = UDim2.new(1,0,1,0) text.Text = names[math.random(1,#names)] 
text.TextColor3 = c.Color text.TextScaled = true text.BackgroundTransparency = 1
for t,k in pairs(workspace[v.Name]:GetChildren()) do
if k:IsA("Part") and k.Name ~= "HumanoidRootPart" then
if k.Name == "Torso" then
k.BrickColor =  c
else
k.BrickColor = BrickColor.new("Medium stone grey")
end
elseif k:IsA("Shirt") or k:IsA("Pants") then
k:Destroy()
elseif k:IsA("Hat") then
if k:FindFirstChild("Handle") then
k.Handle:Destroy()
end
elseif k:IsA("CharacterMesh") then
k:Destroy()
end
end
end
end
end

for i = 10,0,-1 do
wait(.7)
print(i)
end

handout()


2 answers

Log in to vote
1
Answered by 10 years ago

The CharacterAdded event is the easiest and most efficient way of doing that. More information on it can be found here http://wiki.roblox.com/index.php?title=CharacterAdded_(Event)

Ad
Log in to vote
0
Answered by
TomsGames 225 Moderation Voter
10 years ago

To make a script run when a player respawns simply put it into the playergui or starterpack, this must be local but every time the player respawns this script will run.

Answer this question