I’m trying to make arrow images on a Gui turn on and off whenever the signal value is toggled by the script. I am using A-Chassis (but that shouldn’t be part of the issue.)
One thing that I see right now are that you should put Visible after LeftTurn and RightTurn in your script and is your mentioned script inside of kjVehicleGui?
Oh. I forgot, I make that mistake a lot, thanks for looking out for thag. No the mentioned script is not. The script and gui are both child’s of a parent.
It is not. I edited the script so it actually changes the .visible property but the script still fails to find the image label.
Piece of code:
script.Parent:FindFirstChild(“kjVehicleGui”).LeftTurn = false
script.Parent:FindFirstChild(“kjVehicleGui”).RightTurn = false
while true do
wait(0.5)
if vals.Leftsignal == true then
script.Parent:FindFirstChild(“kjVehicleGui”).LeftTurn.Visible = true
script.Parent:FindFirstChild(“kjVehicleGui”).TurnOff:Play()
wait(0.35)
else
script.Parent:FindFirstChild(“kjVehicleGui”).LeftTurn.Visible = false
end
if vals.Rightsignal == true then
script.Parent:FindFirstChild(“kjVehicleGui”).RightTurn.Visible = true
script.Parent:FindFirstChild(“kjVehicleGui”).TurnOff:Play()
wait(0.35)
At runtime, loading the playergui can take some time, so when trying to get any child of a gui at the beginning of runtime, you should use :WaitForChild()
If this gives you a warning after 5 or so seconds, let me know.
I am specifically referring to when you do .LeftTurn.Visible = false, or .TurnOff:Play(), which should be replaced by :WaitForChild("LeftTurn").Visible = false, and :WaitForChild("TurnOff"):Play(), respectively.
I also recommend creating variables for leftTurn, rightTurn, ajnd turnOff, so you would have:
local gui = script.Parent:WaitForChild("kjVehicleGui")
local leftTurn = gui:WaitForChild("LeftTurn")
local rightTurn = gui:WaitForChild("RightTurn")
local turnOff = gui:WaitForChild("TurnOff")
leftTurn.Visible = false
rightTurn.Visible = false
while true do
wait(0.5)
if vals.Leftsignal == true then
leftTurn.Visible = true
turnOff:Play()
wait(0.35)
leftTurn.Visible = false
turnOn:Play()
wait(0.35)
else
leftTurn.Visible = false
end
if vals.Rightsignal == true then
rightTurn.Visible = true
turnOff:Play()
wait(0.35)
rightTurn.Visible = false
turnOn:Play()
wait(0.35)
else
rightTurn.Visible = false
end
end