Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

4 comments

0

u forgot to do then do if function onTouched() == false then

0

It still says that the "if function onTouched() == false then" is untrue. It has a red line unter onTouched

0

Use the TouchEnded API

0

Use the TouchEnded API

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.