Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i am having an error in my code at the = and all of the code is correct whats happening?

ok so i was scripting right because i love roblox (friend me: lukester535 well have a gud teim :) ) and i found an error idk whats happening this works:" function Collide() script.Parent.Transparency = 0 end

script.Parent.ClickDetector.MouseClick:connect(Collide)”

but this:

function Collide() if script.Parent.Transparency = 0 end

script.Parent.ClickDetector.MouseClick:connect(Collide)

doesnt i mean obviosly because i didnt finish but its giving me an error at the “=“ and even if i finish it:

function Collide() if script.Parent.Transparency = 0 then script.Parent.Transparency = 1 end end

script.Parent.ClickDetector.MouseClick:connect(Collide)

i still get it

1 comment

1

and please write it in te blockcode, where it says lua

3 answers

'=' means a declaration or setting a value, as in

local x = 5

So if it's placed in an 'if' statement it will give an error

'==' means if 2 values are equal, as in

if (x == 5) then

Change your 'if' line to the right equals sign

Hi, next time you type a script please put them in code blocks, way easier to read!

Explanation

If statements use '==' instead of '='

Final script

script.Parent.ClickDetector.MouseClick:connect(function()
	if script.Parent.Transparency == 0 then 
		script.Parent.Transparency = 1
	end
end)

Hope this works, if you need any help or got questions ask em!

~ Arthenix

2 comments

0

yeah i found out the answer before you responded

0

^ Please accept my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.