-- Context Of Problem -- My script is being used to make a timed challenge, climbing a "Megatower." The Megatower has two entrances, and after ten seconds starting when the player touches either pad or pad2 the player is teleported to the block "landZone." I created a BoolValue called "debounce" to work for both pads, each having there own scripts, which are identical. However, when I touch either pad, the BoolValue will not change. So I can activate the other pad after activating the first, running two instances of the script, creating odd errors.
-- Question -- How can I have the script turn the BoolValue "debounce" false? script.Parent.Parent.debounce.Value = false won't work. Any ideas on what is wrong, or a fix?
Thanks.
local self = script.Parent
local pad = script.Parent.Parent.Pad
local pad2 = script.Parent.Parent.Pad2
local gate = script.Parent.Parent.InvisEntry
local gate2 = script.Parent.Parent.InvisEntry2
local debounce = script.Parent.Parent.debounce.Value
local speaker = script.Parent.Parent["Megatower Is Ready"]
modelname="landZone"
function onTouch(Brick)
if debounce == false then
local player = Brick.Parent:findFirstChild("Humanoid")
if player ~= nil then
debounce = true
speaker.Name = "Climb On!"
gate.CanCollide = false
gate2.CanCollide = false
pad.BrickColor = BrickColor.new("Bright yellow")
pad2.BrickColor = BrickColor.new("Bright yellow")
wait(10)
local teleportto=script.Parent.Parent:findFirstChild(modelname)
if teleportto~=nil then
local torso = player.Parent.Torso
local location = teleportto.Position
local x = location.x
local y = location.y
local z = location.z
x = x
z = z
y = y
local cf = torso.CFrame
local lx = 0
local ly = y
local lz = 0
torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))
end
speaker.Name = "Megatower Must Reset"
gate.CanCollide = true
gate2.CanCollide = true
pad.BrickColor = BrickColor.new("Bright red")
pad2.BrickColor = BrickColor.new("Bright red")
wait(20)
speaker.Name = "Megatower Is Ready"
pad.BrickColor = BrickColor.new("Bright green")
pad2.BrickColor = BrickColor.new("Bright green")
debounce = false
end
end
end
self.Touched:connect(onTouch)
