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

Whats wrong with local script?

Asked by 8 years ago

ps local script

local player = game.Players.LocalPlayer

If player.Character:FindFirstChild("Head") then
print("found")
end

Error says no character

1 answer

Log in to vote
0
Answered by
4Bros 550 Moderation Voter
8 years ago

Ok, you indexed the variable player to game.Players.LocalPlayer before the LocalPlayer even existed. To prevent from doing that, you should have

repeat wait() until game:GetService'Players'.LocalPlayer and game:GetService'Players'.LocalPlayer.Character

then you can index a variable for them

and you also have a capital I in your if statement, it should be lowercase

repeat wait() until game:GetService'Players'.LocalPlayer and game:GetService'Players'.LocalPlayer.Character
local player = game.Players.LocalPlayer
local character = player.Character

If character:FindFirstChild("Head") then
print("found")
end



Ad

Answer this question