Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Getting error for: if door.Transparency = 0 then ?

Asked by 4 years ago
Edited 4 years ago

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:

--Serverside part for door tween, yeah.

--Stuffs and services.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local revent = ReplicatedStorage.DoorEvent
local door = script.Parent

local function test()
if door.Transparency = 0 then--This is where I was getting the error.
    print("hi")
end



end





revent.OnServerEvent:Connect(test)

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 '='

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago
--Serverside part for door tween, yeah.

--Stuffs and services.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local revent = ReplicatedStorage.DoorEvent
local door = script.Parent

local function test()
if door.Transparency == 0 then --Change the single equal sign to a double equal sign
    door.Transparency = 1
else
    door.Transparency = 0
end



end

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 '=='.

1
To elaborate, the "=" is to change the value. "==" is to compare the two. 7z99 203 — 4y
0
Oh, thanks. I was always wondering what the difference, when I put == sometimes, I get an error saying something about a function, so that helps. VoidKeyword 111 — 4y
Ad

Answer this question