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

How do I define player?

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

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

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