Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why do these functions crash my Roblox Studio when I test the game to test the script?

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

0

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.

2 answers

the "Ziel" Part has CanCollide enabled? if it is, the function may be replicating, and consequently, crashing your game. eventually happens to me, I hope I have helped.

"If the video gives you a lemon, make a Latine Lemonade."

1 comment

0

I made CanCollide False to test the script ( I planned to implement this script into my teleport script which i have in my finish line. ) Maybe I need to change something in the Function

Hm. As a suggestion, you may want to count up with a variable instead of copying the function over an over; I find that sometimes if a script gets "too deep" in logic statements or functions, the tiny errors get harder to find.

I'll edit soon to include some code that features a counting mechanism.

This discussion is preserved as it was. New answers, comments, and votes are closed.