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

Error finding players character with local player?

Asked by 5 years 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
Ankur_007 290 Moderation Voter
5 years ago
Edited 5 years 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. DeceptiveCaster 3761 — 5y
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 290 — 5y
Ad
Log in to vote
0
Answered by
poke7667 142
5 years 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