#whats the best way to get a specific player in a server script?

1 messages · Page 1 of 1 (latest)

true tiger
#

i have a katana which when i unequip its supposed to get the player and character but sometimes i get an error when getting the player because it thinks the katana is in Workspace and not the player

Katana.Unequipped:Connect(function()
    equipped = false
    
    local myplayer = Katana.Parent.Parent
    print(myplayer)
    local mycharacter = myplayer.Character or myplayer.CharacterAdded:Wait()
end

usually it prints the player name, as it should and it works but when i lag or when i spam equip/unequip, it gives me an error because it thinks the katana is in Workspace. so whats the best way to get the player?

stark pollen
#

well, youre just printing the entire player

#

which provides an error

#

and see

true tiger
#

it does print what its supposed to print

#

read it again

stark pollen
#

what does it even print

true tiger
#

but when it errors it prints Workspace

stark pollen
#

wait im so lost

#

how does it print the players name

#

but you can do .Character

#

???

#

show the entire script

true tiger
#

the Katana is a tool

#

when unequipping it goes into the players backpack

#

making Katana.Parent the backpack

#

Katana.Parent.Parent is the player

true tiger
stark pollen
#

how does it even PRINT the players name without .Name

true tiger
#

not the model

#

actually u dont even need .Name when it comes to player

#

as long as its one player

#

actually idk about that

#

i just know it works without .Name

true tiger
#

when it comes to getting the player who equipped and unequipped the tool, what script do you use and if you use a server script, how do you do it?

honest bough