I've got some long code here, but I'll go ahead and give you guys the most important pieces in green.
--This is what happens first when the player steps on the brick.
d=true
script.Parent.Touched:connect(function(hit)
if d and hit.Parent:FindFirstChild("Humanoid") and script.Parent.BrickColor~=BrickColor.Green() then
d=false
local plr=game.Players:FindFirstChild(hit.Parent.Name)
hit.Parent.Humanoid.WalkSpeed=0
plr.Character.JumpDisabled.Disabled=false
script.Parent.BrickColor=BrickColor.Green()
plr.Court.Value=script.Parent.Parent.Name
plr.team.Value = "Home"
hit.Parent.Torso.CFrame=CFrame.new(script.Parent.t.Position)
script.Parent.Parent.gotnext.Value=script.Parent.Parent.gotnext.Value+1
plr.PlayerGui.scoreboard:findFirstChild(script.Parent.Parent.Name).Visible=true
plr.TeamColor=BrickColor.new("Mid gray")
script.Parent.Sound:Play()
wait(1.33)
script.Parent.Sound:Stop()
d=true
end
end)
--This is a GUI that makes them be removed from the Brick.
local part=game.Workspace.Part1 -- the part you want to teleport the player to teleport to
local d=true -- debounce
local plr = game:GetService("Players"):FindFirstChild("Humanoid")
script.Parent.Touched:connect(function(limb)
if limb.Parent:FindFirstChild("Humanoid") then
d=false
local RepStorage = game:GetService("ReplicatedStorage")
local plr=game:GetService("Players"):FindFirstChild(limb.Parent.Name)
local playerGui = plr:WaitForChild('PlayerGui')
local ExitCourt = RepStorage.ExitCourt
local EC = ExitCourt:Clone() --Cloned GUI
EC.Parent = playerGui
EC.TextButton.Visible = true
local button = EC.TextButton
d=true
button.MouseButton1Down:connect(function()
plr.Character.Torso.CFrame=part.CFrame+Vector3.new(0,2,0)
EC:Destroy() --Won't destroy on first click (Link down below)
script.Parent.Parent.gotnext.Value = script.Parent.Parent.gotnext.Value - 1
plr.PlayerGui.scoreboard:findFirstChild(script.Parent.Parent.Name).Visible=false
script.Parent.BrickColor=BrickColor.Blue()
plr.Team = game.Teams["No Team"]
limb.Parent.Humanoid.WalkSpeed=16
plr.team.Value = ""
plr.Court.Value=game.Workspace.nocourt.Name
plr.Character.JumpDisabled.Disabled=true
end)
elseif plr.Court.Value==game.Workspace.nocourt then --Just a different value, still works.
if d==true then
d=false
local RepStorage = game:GetService("ReplicatedStorage")
local plr=game:GetService("Players"):FindFirstChild(limb.Parent.Name)
local playerGui = plr:WaitForChild('PlayerGui')
local ExitCourt = RepStorage.ExitCourt
local EC = ExitCourt:Clone() --Cloned GUI
EC.Parent = playerGui
EC.TextButton.Visible = true
local button = EC.TextButton
button.MouseButton1Down:connect(function()
plr.Character.Torso.CFrame=part.CFrame+Vector3.new(0,2,0)
EC:Destroy() --Won't destroy on first click (Link down below)
script.Parent.Parent.gotnext.Value = script.Parent.Parent.gotnext.Value - 1
plr.PlayerGui.scoreboard:findFirstChild(script.Parent.Parent.Name).Visible=false
script.Parent.BrickColor=BrickColor.Blue()
plr.Team = game.Teams["No Team"]
limb.Parent.Humanoid.WalkSpeed=16
plr.team.Value = ""
plr.Court.Value=game.Workspace.nocourt.Name
plr.Character.JumpDisabled.Disabled=true
d=true
end)
end
else
return
end
end)
Visual Representation: Gyazo GIF
Thanks for all the support, any answer will be accepted as long as it's helpful (:
-LukeGabrieI aka EnergyBrickz

1 comment
EC is available only in one function, you used a unknown object in a new function, I suggest you to add new detection to that object, Use : EC2 = game.Players.LocalPlayer.PlayerGui.("Object name" or I can say "EC") Copy this cod below your Mouse Button Function.