So i tried making a Lever that when i click on the Hitbox (ClickDetector) that it will make 1 part transparent and the other one not so it looks like the lever is pulled.
I tired making a scirpt altough is suck at scripting.
i made this.
function game.Workspace.SwitchTrack1.HandlePart1.Transparency = 1 else game.Workspace.SwitchTrack2.HandlePart1.Transparency = 0 end script.Parent.Show.Click.MouseClick:connect(act)
Anyone can help me with my script? Would be very appericiated.
So your problem is that you don't have a function for this script, it doesn't know what to do. So here's a fixed script for you.
function(act) print("Lever was pulled.") game.Workspace.SwitchTrack1.HandlePart1.Transparency = 1 game.Workspace.SwitchTrack2.HandlePart1.Transparency = 0 end script.Parent.Show.Click.MouseClick:Connect(act)
Learn proper Lua before you even try scripting. A lot of your syntax is already wrong. Namely the if control sequence and how you declare a function.
Here's their official guide. https://www.lua.org/pil/contents.html
Here's the fixed script if you want.
local function LeverClicked() workspace.SwitchTrack1.HandlePart1.Transparency = 1 --make the first lever part invisible. workspace.SwitchTrack2.HandlePart1.Transparency = 0 --make the first lever part visible again. end script.Parent.Show.Click.MouseClick:connect(LeverClicked)
And in anonymous functions if you want.
script.Parent.Show.Click.MouseClick:connect(function () workspace.SwitchTrack1.HandlePart1.Transparency = 1 --make the first lever part invisible. workspace.SwitchTrack2.HandlePart1.Transparency = 0 --make the first lever part visible again. end)