local Players = game:GetService("Players")
local LocalPlr = Players.LocalPlayer.Character.Name
local userId = Players:GetUserIdFromNameAsync(LocalPlr) -- later it will be"AamTum" (Local Player)
how do i make it work using local player/ self player char
ive tried using LocalPlayer.char but still, im using a script that’’ run on workspace
because i wanted to make a statue using it
where did i go wrong
local Players = game:GetService("Players")
local LocalPlr = Players.LocalPlayer.Character.Name
local userId = Players:GetUserIdFromNameAsync(LocalPlr) -- later it will be"AamTum" (Local Player)
Better:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local username = Player.Name
local userId = Player.UserId
If you’re using a server script you won’t be able to get the local player’s name because there is no local player on the server. The local player refers directly to the player that’s controlling a client.
@bioeless Was correct: The issues you’re experiencing are happening because you’re using a server Script instead of a LocalScript. LocalScripts don’t work inside of Workspace, and aren’t able to use LocalPlayer, so the easiest way to fix your problem would be to do this:
Go to your script’s properties tab
Change its RunContext to Client
This will make the server Script behave as a LocalScript, which will allow you to use LocalPlayer, and allow the script to run inside of Workspace
bioeless deserves the solution more than I do, since they managed to accurately guess the main problem before the screenshot was posted