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 find a player a different way?

Im trying to locate a local player without using

game.Players.LocalPlayer

Because that does not work with regular scripts. how would i make that work?

3 comments

0

Can you clarify what you want to do?

0

Can you clarify what you want to do?

0

Of course it doesn't work in "regular" Scripts. In reality, those are ServerScripts (Server-sided Scripts). The Server's purpose is to manage and replicate to Clients**, it is not a user, therefore it will have no Player.

2 answers

The scripts that run on the server are independent of any single player.

So in order to pinpoint a specific player within a server script, you would have to know what sets them apart from everyone else.

However, if you wanted to manage every player at the time they joined, then you should use the PlayerAdded event:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	print(player.Name .. " has joined!")
end)

continued from Amanda's one

If your making a tool/gear then you can use

function Equipped()
	local Character = script.parent.parent
	local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
end
script.Parent.Equipped:Connect(Equipped)

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