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

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

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

4 comments

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

0

do you want to get player who touched something or clicked a click detector or triggered proximity prompt?

0

i'm trying to make a blood system

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.

1 answer

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

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