feltive 69
feltive 69

Reputation: 1

roblox LUA Expected 'end' (to close 'than' at line 3), got '='

function teleportTo(placeCFrame)
    local plyr = game.Players.LocalPlayer;
    if plyr.Character then
        return plyr.Character.HumanoidRootPart.CFrame = placeCFrame; 
    end
end

teleportTo(game:GetService("Workspace").game:GetService("Workspace").Zeppelin.FuelTank1.Tank.CFrame)

my code is here, idk much about coding thanks for helping and if you told me how to make the player teleport to a moving object it would be so super

Upvotes: 0

Views: 356

Answers (2)

Cmb
Cmb

Reputation: 394

The reason you are getting an error is because = is usually defined as setting a value, and no code can be executed after a return or it will error

If you wanted to, you could add return after all the code is done executing

Upvotes: 0

Kylaaa
Kylaaa

Reputation: 7188

The error is telling you what is going on.

When the code was being interpreted line by line, it expected the next symbol to be end, but instead it got =.

That means that something about how you're using the equals sign is incorrect. So when we look at the line :

return plyr.Character.HumanoidRootPart.CFrame = placeCFrame

You cannot assign a value on the same line as a return command. return is used to pipe a value out of a function so it can be used where the function was called.

But I'm pretty sure that isn't what you intended, you just want to set a player's position. So to fix your issue, remove the return.

if plyr.Character then
    plyr.Character.HumanoidRootPart.CFrame = placeCFrame
end

Upvotes: 3

Related Questions