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

can't get player's character from server script?

Asked by 2 years ago
local plr = game:GetService("Players")
local Char = plr.Character or plr.CharacterAdded:Wait()

i'm trying to get player's character but it doesn't work.

this is what the error says from the script: " Character is not a valid member of Players 'Players' " Line 2

anyways, this is Server Script

0
you are trying to get .Character property of Players service which does not exist at all, with LocalScript you can try plr.LocalPlayer property, in server script you can't do this, you need to know which exact player you want to get imKirda 4491 — 2y
0
do you want to get player who touched something or clicked a click detector or triggered proximity prompt? imKirda 4491 — 2y
0
i'm trying to make a blood system vendinY 5 — 2y
0
okay, you want to deal blood when someone touched sword for example? .Touched will pass part that touched parameter from which you can get the player, you always have some kind of variable from which you can get the player, whether his limb, character or stuff like that. imKirda 4491 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

game:GetService("Players") (similiar to game.Players) is a folder of all players connected to a server. plr.Character and plr.CharacterAdded:Wait() are the properties and events of specific player (not game.Players!!!). If you run a game, you can see your name in the game.Players folder, and game.Players.[your_name].Character and game.Players.[your_name].CharacterAdded:Wait() will work. Players and Player is a big difference, one of wich works like a folder and the second is a player himself

Players

Player

Ad

Answer this question