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

How do I define player?

Asked by 8 years ago

I want to make a allow door to certain people using this. But I don't have player defined . Is it game.Players.LocalPlayer in game it doesnt work?

player.Name == "PlayerName"

1 answer

Log in to vote
1
Answered by 8 years ago

To get this in a LocalScript:

local player = game.Players.LocalPlayer

If you want a V.I.P. door thing.. you use a ServerScript or Script where the method is different.

In A Part:

local door = script.Parent -- Define the door

door.Touched:connect(function(hit) --Touched function where hit is the part that touches the door
    if hit.Parent:FindFirstChild("Humanoid") then --If the part that touched has a humanoid
        if hit.Parent.Name == "Player1" then --If statement that checks the person who touched's name
            door.CanCollide = false
            door.Transparency = 0.5
            wait(3)
            door.CanCollide = true
            door.Transparency = 0
        end
    end
end)

http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched http://wiki.roblox.com/index.php?title=Restricted_door http://wiki.roblox.com/index.php?title=API:Class/Players/LocalPlayer

Ad

Answer this question