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

GetChildren [CanCollide/Transparency Onclick?]

Asked by 10 years ago

I'm trying to make the Children of these bricks CanCollide True/False And transparency change OnClick. Here's my Script.

local isOn = true

function on() isOn = true script.Parent.Pos1.GetChildren().CanCollide = true script.Parent.Pos1.GetChildren().Transparency = 0 script.Parent.Pos2.GetChildren().CanCollide = false script.Parent.Pos2.GetChildren().Transparency = 1 end

function off() isOn = false script.Parent.Pos1.GetChildren().CanCollide = false script.Parent.Pos1.GetChildren().Transparency = 1 script.Parent.Pos2.GetChildren().CanCollide = true script.Parent.Pos2.GetChildren().Transparency = 0 end

function onClicked()

if isOn == true then off() else on() end

end

script.Parent.Pos1.GetChildren().ClickDetector.MouseClick:connect(onClicked) script.Parent.Pos2.GetChildren().ClickDetector.MouseClick:connect(onClicked)

on()

1 answer

Log in to vote
0
Answered by
LAC44 20
10 years ago

This should work:

local isOn = true

function on() isOn = true script.Parent.Pos1.GetChildren().CanCollide = true script.Parent.Pos1.GetChildren().Transparency = 0 script.Parent.Pos2.GetChildren().CanCollide = false script.Parent.Pos2.GetChildren().Transparency = 1 end

function off() isOn = false script.Parent.Pos1.GetChildren().CanCollide = false script.Parent.Pos1.GetChildren().Transparency = 1 script.Parent.Pos2.GetChildren().CanCollide = true script.Parent.Pos2.GetChildren().Transparency = 0 end

function onClicked()

if isOn == true then off() else on() end
end

script.Parent.Pos1.MouseButton1Down:connect() --I think you were doing this part wrong 
script.Parent.Pos2.MouseButton1Down:connect() 

on()
0
Thanks. ben10is10 0 — 10y
Ad

Answer this question