Can anyone see a problem with what is indexed below? I have made sure the variables are correctly found, I have tested this script in game with a report-error thing, and it doesn't show an error. (Yes, there is more to the script, this is just a piece of it.)
1 | elseif string.sub(string.lower(msg), 1 , 13 ) = = "openFrontDoor" then |
2 | mdoor.Transparency = 0.4 |
3 | mdoor.CanCollide = false |
4 | elseif string.sub(string.lower(msg), 1 , 14 ) = = "closeFrontDoor" then |
5 | mdoor.Transparency = 0 |
6 | mdoor.CanCollide = true |
1 | elseif string.sub(string.lower(msg), 1 , 13 ) = = "openfrontdoor" then |
2 | mdoor.Transparency = 0.4 |
3 | mdoor.CanCollide = false |
4 | elseif string.sub(string.lower(msg), 1 , 14 ) = = "closefrontdoor" then |
5 | mdoor.Transparency = 0 |
6 | mdoor.CanCollide = true |
Your script was not working because you were calling string.lower on the message, which makes all letters lowercase, then comparing it to a string that contains capital letters.
There's supposed to be a space in between else and if. I know I didn't fully answer this because I'm new to scripting also, but this is what I know.
1 | else if string.sub(string.lower(msg), 1 , 13 ) = = "openFrontDoor" then |
2 | mdoor.Transparency = 0.4 |
3 | mdoor.CanCollide = false |
4 | else if string.sub(string.lower(msg), 1 , 14 ) = = "closeFrontDoor" then |
5 | mdoor.Transparency = 0 |
6 | mdoor.CanCollide = true |