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

Learning RLUA, how does LocalPlayer work, as it doesn't work ingame but it does in studio?

Asked by 7 years ago

b = script.Parent

function onTouched(plr) game.Players.LocalPlayer.Team = game.Teams["Blue"]
end

b.Touched:connect(onTouched)

2 answers

Log in to vote
0
Answered by
Astilev 30
7 years ago

I assume in this case, b would be a part.

When a part is touched, the hit is not the actual player, but a limb of the model of the player in the workspace.

So you end up with

b = script.Parent

function onTouched(hit)
    name = hit.Parent.Name --storing the name of the player you hit
    for i,v in pairs (game.Players:GetChildren()) do --finding the player in game.Players
        if v.Name == name then
            v.Team = place in the team
        end
    end
end

b.Touched:connect(onTouched)
Ad
Log in to vote
0
Answered by 7 years ago

You cannot access LocalPlayer in a ServerScript. The reason it works in studio is because it only has one player, but with servers, they have multiple players. So the server script is just like "What player am I supposed to choose?!" Also, you should use code blocks when displaying code.

Answer this question