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

checking if something exists in localplayer?

Asked by 10 years ago

I want to check if something exists within the local player, if it doesn't, I want something to happen. How do I do this?

2 answers

Log in to vote
3
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

The FindFirstChild method will return true if it finds the specified object. In your LocalScript, put something like this:

if game.Players.LocalPlayer:FindFirstChild("NameOfObjectHere") then
    --do stuff
end

Hope this helps!

Also note that LocalPlayer only exists to the client, and referencing it needs to be done through a LocalScript (as I'm sure you are aware).

Ad
Log in to vote
0
Answered by 10 years ago
if game.Players.LocalPlayer:FindFirstChild("NameHere") then
    --Script
    else
    print("Error can't find object in localplayer")
end

This needs to be a local script

Answer this question