Hi, I'm trying to make a door script, and I wanna check if the door's transparency is 0 and then change it to 1, and if it's not, change it to 0. Here's my code:
01 | --Serverside part for door tween, yeah. |
02 |
03 | --Stuffs and services. |
04 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local revent = ReplicatedStorage.DoorEvent |
06 | local door = script.Parent |
07 |
08 | local function test() |
09 | if door.Transparency = 0 then --This is where I was getting the error. |
10 | print ( "hi" ) |
11 | end |
12 |
13 |
14 |
15 | end |
I don't really understand why I can't check if the door is transparent and then do a specific function. this is the error by the way: 20:30:05.143 - Workspace.Door1.Script:9: Expected 'then' when parsing if statement, got '='
01 | --Serverside part for door tween, yeah. |
02 |
03 | --Stuffs and services. |
04 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local revent = ReplicatedStorage.DoorEvent |
06 | local door = script.Parent |
07 |
08 | local function test() |
09 | if door.Transparency = = 0 then --Change the single equal sign to a double equal sign |
10 | door.Transparency = 1 |
11 | else |
12 | door.Transparency = 0 |
13 | end |
14 |
15 |
16 |
17 | end |
18 |
19 | revent.OnServerEvent:Connect(test) |
Edit: Sorry forgot to put an explanation in
So for what 7z99 was saying putting a single '=' sign is more for setting values. In order to compare information you need to use a '=='.