Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Error finding players character with local player?

Asked by 2 months ago
local Remote = game.ReplicatedStorage.Remotes.GigantificationRemotes.GigantificationFire





Remote.OnServerEvent:Connect(function(Player,Mouse)

local player = game.Players.LocalPlayer

local character = player.Character

while true do

wait(0.25)

character.Torso.Size = character.Torso.Size + 1,1,1

wait(4) break

end

end)

getting an error at "local character"

2 answers

Log in to vote
1
Answered by 2 months ago
Edited 2 months ago

The server can't use game.Players.LocalPlayer, it's client-only. If you want the character you can simply use the Character property of the Player argument passed as such: ```lua -- If you're sure the character is there local character = Player.Character

-- If the character might not have been made yet local character = Player.Character or Player.CharacterAdded:Wait() ``` Hope this helps you, feel free to ask any questions or point out mistakes and I'll try my best to help :)

0
Line 5 should be Player:WaitForChild("Character"). It will actually wait until it exists. RobloxWhizYT 2026 — 2mo
0
No, Character is a property of the Player instance and waiting for a child named "Character" will not work. The way the fifth line works is that if Player.Character is nil, Player.CharacterAdded:Wait() makes the script yield until the CharacterAdded event fires and then returns the character as an instance (as CharacterAdded passes a character argument when fired) Ankur_007 68 — 2mo
Ad
Log in to vote
0
Answered by 2 months ago

Assuming this script is on the server side, you cannot use game.Players.LocalPlayeron it. Since you already passed a Player parameter, use that instead of LocalPlayer.

Answer this question