Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this script an "If" statement?

Asked by 6 years ago
Edited 6 years ago

This is what I've made

bridge = script.Parent.Parent.bridge

function onTouched() 
    bridge.CanCollide = true
    bridge.Transparency = 0
end
script.Parent.Touched:connect(onTouched)

but I want it to do this

bridge = script.Parent.Parent.bridge

if function onTouched() == false then
    bridge.CanCollide = true
    bridge.Transparency = 0
else
    bridge.CanCollide = false
    bridge.Transparency = 1
end
script.Parent.Touched:connect(onTouched)
0
u forgot to do then do if function onTouched() == false then tacotown2 119 — 6y
0
It still says that the "if function onTouched() == false then" is untrue. It has a red line unter onTouched crocman132 0 — 6y
0
Use the TouchEnded API cmgtotalyawesome 1418 — 6y
0
Use the TouchEnded API cmgtotalyawesome 1418 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
local bridge = script.Parent.Parent.bridge

local function onTouch(part)
    bridge.CanCollide = true
    bridge.Transparency = 0
end

local function onTouchEnded(part)
    bridge.CanCollide = false
    bridge.Transparency = 1
end
bridge.Touched:Connect(onTouch)
bridge.TouchEnded:Connect(onTouchEnded)

This is what I came up with

Ad

Answer this question