Hello. I am making a tycoon and I was making a button when I decided to test it. And to check the working of it, I decided to make some prints:
01 | model = script.Parent.Parent.Parent.Factory.D 1 |
02 | cost = 0 |
03 |
04 | local backup = model:Clone() |
05 | backup.Parent = game.ServerStorage.Objects |
06 | model:Destroy() |
07 |
08 | -- we only need what's below this line |
09 | script.Parent.Head.Touched:connect( function (h) |
10 | if h.Parent.Name = = game.Players:FindFirstChild(h.Parent.Name) then |
11 | if h.Parent.Name = = script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value then |
12 | local playername = h.Parent.Name |
13 | if game.Players [ playername ] .leaderstats.Money.Value > = cost then |
14 | game.Players [ playername ] .leaderstats.Money.Value = game.Players [ playername ] .leaderstats.Money.Value - cost |
15 | backup.Parent = script.Parent.Parent.Parent.Factory |
But when I step with an player on it, it says always "This isn't a player" Why??? Need more info?
if h.Parent.Name == game.Players:FindFirstChild(h.Parent.Name) then
You're comparing a string with an object!, hit.Parent.Name is a string and game.Players:FindFirstChild(h.Parent.Name) is going to be the player object. They will never match even if the player exists.
You should just check if game.Players:FindFistChild(h.Parent.Name)
exists.
1 | if game.Players:FindFirstChild(h.Parent.Name) then |