Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR LUA

Best way to get player from character?

-- Do it easy bro
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Character)
		print(plr)
        print(Character)
	end)
end)

-- There is more events like part.Touched to get the player too
-- Notice now we get the player searching the name of it? Thats how you get it
local myPart = script.Parent -- This Script is in a part from the Workspace
myPart.Touched:Connect(function(hit) -- Player touches the thing 
	local character = hit.Parent
	local humanoid = character:FindFirstChild("Humanoid")
	local player = game.Players:FindFirstChild(char.Name)
    
    -- Prevent other stuff touching that part to trigger your code
    if humanoid then
      -- Kill Player MUAHAHA
    end
end)
 
PREVIOUS NEXT
Tagged: #Best #player
ADD COMMENT
Topic
Name
3+6 =