Hello, i'm trying to learn scripting and making a game. I want to have a Gui to tell who touched the finish line during a round in my game. I tested it with only one function to tell who was first and it worked fine. It made a decal visible and told the name of the player. Now I wanted to add nine more functions to tell who touched it next, showing up as 2nd. Then continue with 3rd, 4th, 5th, ...
Why does this script now immediately crash my Studio when I test it?
Are these too many functions in a script to work?
How do I need to put the functions to have the Gui tell who touched it second, third and so on? People get teleported by another script right after they reach the finish line and another script also adds a win in leaderboard.
I hope you can give me a hint, what I need to figure out and how I can fix this. Output doesnt tell any errors for the script itself.
player = game.Players.LocalPlayer
name = player.Name
workspace.Ziel.Touched:connect(function(hit)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Text = name
script.Parent.ImageLabel.Visible = true
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Second
workspace.Ziel.Touched:connect(function(hit2)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Second.Text = "2nd: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Third
workspace.Ziel.Touched:connect(function(hit3)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Third.Text = "3rd: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Fourth
workspace.Ziel.Touched:connect(function(hit4)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Fourth.Text = "4th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Fifth
workspace.Ziel.Touched:connect(function(hit5)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Fifth.Text = "5th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Sixth
workspace.Ziel.Touched:connect(function(hit6)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Sixth.Text = "6th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Seventh
workspace.Ziel.Touched:connect(function(hit7)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Seventh.Text = "7th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Eigth
workspace.Ziel.Touched:connect(function(hit8)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Eigth.Text = "8th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Ninth
workspace.Ziel.Touched:connect(function(hit9)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Ninth.Text = "9th: " ..name
wait(1)
game.Workspace.Ziel.Locked = false
end
-- Tenth
workspace.Ziel.Touched:connect(function(hit10)
if game.Workspace.Ziel.Locked == false then game.Workspace.Ziel.Locked = true
script.Parent.Ninth.Tenth = "10th: " ..name
wait(1)
end
end)
end)
end)
end)
end)
end)
end)
end)
end)
end)

1 comment
You don't need to connect these many events, and you should only connect the Touched event once. Otherwise, I don't see anything wrong, but you probably should want to use a variable instead of the Part's Locked property.