Expected identifier when parsing expression, got '=' fix?

Alright, so I have a script that teleports the player I got off of the toolbox because I don’t know how to write these, anyways it checks if a value in the workspace is true, if it is then it will teleport the player. at line 20 it says

Expected identifier when parsing expression, got ‘=’

I kind of get what this means, but not enough to fix it. The code line is: (error at last equal sign)

humanoid.Parent.Torso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0)) or humanoid.Parent.UpperTorso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))

For context, this is the whole script. Server script inside of workspace. Error at line 20

local folder = workspace.TeleportGui.teleportparts
local tools = folder:GetChildren()


local part = tools[math.random(1, #tools)]


script.RemoteFunction.OnServerInvoke = function(player)
	local humanoid = player.Character.Humanoid
	if humanoid.Parent:FindFirstChild("Torso") then
		humanoid.Parent.Torso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))
	elseif humanoid.Parent:FindFirstChild("UpperTorso") then
		humanoid.Parent.UpperTorso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))
	else
		print("no torso/uppertorso was found in player "..player.Name)
	end
	
	if workspace.isround.Value == true and humanoid.Parent:FindFirstChild("Torso") or humanoid.Parent:FindFirstChild("UpperTorso") then
		wait(1)
		humanoid.Parent.Torso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0)) or humanoid.Parent.UpperTorso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))
			print("its true")
			--
		
	elseif workspace.isround.Value == false then
		print("its false")
		
		else
		print("no torso/uppertorso was found in player "..player.Name)
		
	end
end

I don’t think you can have conditionals in statements like that. Only if statements can have or

1 Like

Should probably use the ternary operator for this (Or something)

Try this perhaps?

local folder = workspace.TeleportGui.teleportparts
local tools = folder:GetChildren()


local part = tools[math.random(1, #tools)]


script.RemoteFunction.OnServerInvoke = function(player)
	local humanoid = player.Character.Humanoid
    local MainTorso = player.Character:FindFirstChild("Torso") or player.Character:FindFirstChild("UpperTorso")
	if MainTorso then
        MainTorso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))
	else
		print("no torso/uppertorso was found in player "..player.Name)
	end
	
	if workspace.isround.Value == true and MainTorso then
    
		wait(1)
		MainTorso.CFrame = CFrame.new(part.Position + Vector3.new(0,3,0))
			print("its true")
			--
		
	elseif workspace.isround.Value == false then
		print("its false")
		
		else
		print("no torso/uppertorso was found in player "..player.Name)
		
	end
end
2 Likes

ah, so you have to move the or to the variable. got it, thanks for the help and the re-written script.

Yeah

I suppose you could think of it like this

local Orange = workspace.Part or Instance.new("Part")

Say we’re assuming that we have a “Orange” inside the workspace, but what if it isn’t? Well, we can use that or statement to check if it’s nil & if it is, it’ll pass onto the next conditional structure (Or creating a Part with Instance.new()& we can still keep our part

1 Like