I tried doing:
local hh = hit.Parent.Name
game.Players.hh
But it came out with an error saying that hh is not a valid member of Players.
Can if so, how do I put hh into game.Players.hh?
I tried doing:
local hh = hit.Parent.Name
game.Players.hh
But it came out with an error saying that hh is not a valid member of Players.
Can if so, how do I put hh into game.Players.hh?
Using the FindFirstChild function of ROBLOX instances, you can do just what you are attempting. The function returns the player corresponding to the passed argument, or nil.
local variable = 'Player'
if game.Players:FindFirstChild(variale) then
print('isPlayer')
else
print('no')
end
Thanks! That was the solution to my problem!
Yup, if you wouldn't mind, do please accept my answer by clicking the "accept answer" button located to the right
:FindFirstChild is a good thing to do -- it's necessary when you aren't absolutely sure there is an object there.
It's also a useful fact that object.index is just sugar -- it's the same thing as indexing by a string; object.index is the same thing as object["index"].
game.Workspace
-- same as
game["Workspace"]
-- or the same as
serviceName = "Workspace"
game[serviceName]
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
The Error is telling you there is no such Child named 'hh' within the Players Service, thus the 'hh is not a valid member of Players', this can, however, be fixed by using Brackets, however, I'd recommend using 'FindFirstChild' first.