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

Why does "Expected identifier when parsing expression" show up here?

I was trying to make a script for the part to fade out after a player clicks it; then I made a simple debounce using 'clickDet.MaxActivationDistance' so players can't click the part before it actually turns fully transparent...

local part = script.Parent.Parent
local clickDet = script.Parent

clickDet.MouseClick:Connect(function()
	if part.Transparency == 0 then
		for i = 0, 1, 0.01 do
			part.Transparency = i --Cool transparency effect
			
			clickDet.MaxActivationDistance = 0
			
			if part.Transparency == 0.99 then 
				part.Transparency = 1 and clickDet.MaxActivationDistance = 32 --Error here.
			end	
			wait()
		end
	else
		part.Transparency = 0
	end
end)

The error seems to be "Expected identifier when parsing expression, got '=' ". Why does it even show up here?

2 comments

0

I suggest removing the 'and' and put clickDet.MaxActivationDistance on a seperate line. Use and or not only for if statements or variables (using only or.)

0

Thanks, my bad. I'll continue on improving my skills...

1 answer

✓ Accepted answer

You can't assign things using and, what you want is

if part.Transparency == 0.99 then
	part.Transparency = 1 
	clickDet.MaxActivationDistance = 32
end

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