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)