Game ending won't initiate

Hi, my code won’t run whenever a person touches a part. I have code before it that works but the end won’t work. Does anyone have any solutions? I know the code is messy, that’s because I modified other scripts and put them here. Also ignore the comments.

LocalScript
local text = script.Parent
local click = game.Workspace.ButtonStand.Button.ClickDetector

wait(1)

text.Text = "Oh."

wait(2)

text.Text = "Hi there."

wait(3)

text.Text = "You might be wondering why you are here, or where you came from."

wait(5)

text.Text = "That doesn't matter. Just do anything, but whatever you do, DO NOT press the button."

wait(7)

text.Text = " "

click.MaxActivationDistance = 32

click.MouseClick:Connect(function()
	game.Workspace["Teleport-1"].Transparency = 0
	for _, part in pairs(game.Workspace["Grassy maze"]["Hedge Maze"]:GetChildren()) do
		part.Transparency = 0
	end
	text.Text = "Oh look, that blue thing!"
	
	wait(3)
	
	text.Text = "Maybe you should walk up to it."
end)

local Teleport = "Teleport-2" --Put the name of the Part between the ""s.
function Touch(hit) --Indicates that the Part has been Touched.
	if game.Workspace["Teleport-1"].Locked == false and game.Workspace:findFirstChild(Teleport).Locked == false then game.Workspace["Teleport-1"].Locked = true game.Workspace:findFirstChild(Teleport).Locked = true --Checks Debounce.
		local Pos = game.Workspace:findFirstChild(Teleport) --Gets the Part to teleport to.
		hit.Parent:moveTo(Pos.Position) wait(1) game.Workspace["Teleport-1"].Locked = false game.Workspace:findFirstChild(Teleport).Locked = false 
		text.Text = "Oh, a maze! You need to escape it!" 
		game.Workspace["Teleport-1"]:Destroy()
		game.Workspace["Teleport-2"]:Destroy() 
		wait(4)
		text.Text = " "
		for _, part in pairs(game.Workspace["obby+end"].obby["parkour 1"]:GetChildren()) do
			part.Transparency = 0 end end end--Takes you there and Ends the Function.
game.Workspace["Teleport-1"].Touched:connect(Touch) --Listens out for Touchers.

game.Workspace["obby+end"].obby["parkour 1"].EndPart.Touched:Connect(function(hit)
	text.Text = "Great job, you made it to the end!"
	wait(3)
	text.Text = "Umm... that's it for this game."
	wait(3)
	text.Text = "I guess that button wasn't so bad after all."
	wait(4)
	local player = hit.Parent
	game:GetService("BadgeService"):AwardBadge(player.UserId, 2127268881)
	player:Kick("You made it to the end of the game!")
end)

i dont know how to make it myself just that u are missing a ton of things there.

I cant play it now because my laptop keeps getting error 0x887a0006 and Studio crashes.

Are you receiving any errors from the output? If so could you please show us the error?

No, nothing except possible infinite yields from other plugins I’m not using right now

And also sometimes the GUI restarts to the beginning if I die at the obby and then it says the teleport is missing, which should happen because it was destroyed by me.

Also remember that it is a local script because of the GUI

localscripts cannot award badges. You’d have to remake the script as both a localscript for client-side GUI and server-side functions - you can use Remote Functions and Events to accomplish this; have them communicate to achieve your intended end state.

2 Likes

This bug is actually happening to me, and i cant figure out how to fix it. Im trying to develop and it keeps crashing my studio at really really random times. Since i cannot make a Studio Bug Report it can’t really get any further help on this.