ClickDetector.CursorIcon changing in script, but not while in function, why?
Hello. I made a script that changes the door handle clickdetector icon depending on if it is open or not.
02 | openIcon = "6081347829" |
03 | closeIcon = "6081348044" |
04 | knockIcon = "6081347938" |
05 | chainIcon = "6081348125" |
06 | outerPlace = script.Parent.Parent.OuterKnob.OuterKnob.ClickDetector |
07 | innerPlace = script.Parent.Parent.InnerKnob.InnerKnob.ClickDetector |
08 | bodyPlace = script.Parent.Parent.DoorBody.ClickDetector |
09 | chainPlace = script.Parent.Parent.HalfLockAccept.ClickDetector |
11 | bodyPlace.CursorIcon = prefix..knockIcon |
12 | chainPlace.CursorIcon = prefix..chainIcon |
13 | outerPlace.CursorIcon = prefix..openIcon |
14 | innerPlace.CursorIcon = prefix..openIcon |
16 | function onDoorStateChange(value) |
17 | if (value = = true ) then |
18 | outerPlace.CursorIcon = prefix..closeIcon |
19 | innerPlace.CursorIcon = prefix..closeIcon |
21 | outerPlace.CursorIcon = prefix..openIcon |
22 | innerPlace.CursorIcon = prefix..openIcon |
26 | script.Parent.stateChange.Event:Connect(onDoorStateChange) |
The icon gets changed as soon as the server starts and as this script is ran, but when the event is fired and the function is ran, it doesn't change. The if statement works, I tested it in the debugger. Also in the watch window, the outerPlace.CursorIcon and innerPlace.CursorIcon variables change but these changes aren't reflected in the game.
Does anyone have any idea why it doesn't change?