hello scripters! im trying to call the players model but theres a problem
the problem i don’t know how to call the player
i tried using a localscript but no luck heres what i tried
local player = player
as you can see im very stuck
hello scripters! im trying to call the players model but theres a problem
the problem i don’t know how to call the player
i tried using a localscript but no luck heres what i tried
local player = player
as you can see im very stuck
When you say the player’s “model”, I’m assuming you mean the literal object with the player’s name in the Players
service. You should run something like this on a localscript.
local player = game.Players.LocalPlayer -- we got the "Player" model from game.Players
-- Some examples with player
player:FindFirstChild("PlayerGui")
player:FindFirstChild("PlayerScripts")
PlayerGui
and PlayerScripts
are part of the game.Players.LocalPlayer
instance.
Okay great start, proper variable names and using ‘local’ is good practice when you’re learning.
In both Local and Server scripts, we use the ‘game’ variable to access all objects in our games.
In this case, the path to the player object is:
local player = game.Players.LocalPlayer
-- If you open the Explorer window in the View tab - you can see the different objects and their names that you can reference.
Do note, ‘LocalPlayer’ doesn’t work in Server scripts.
As for the player’s “model”, it is called the ‘Character’.
local player = game.Players.LocalPlayer
local character = player.Character
You can find out more about the Player object, as well as other objects on Roblox’s Developer Hub
Player (roblox.com)
There are a couple of ways/alternatives on obtaining the Player’s Model, unless if you meant the Object itself, either way but I’ll just show the common use
You could just call this on a LocalScript
as you’re capable of defining the LocalPlayer
easily:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
@WingItMan Not sure if you know this, but there is the possible chance that the script may not detect the Character
property entirely, so we put a CharacterAdded:Wait()
in case our first check doesn’t work