fret13103Join Date: 2010-03-15 Post Count: 881 |
I'm having trouble navigating inside the player model
I have a touched event, and I'm using "hit"
(I have instantiated the "hit", and checked "hit.Parent" has a "Humanoid" in it)
So when I try to do this:
hit.Parent.leaderstats.Money
It's like I'm in the completely wrong area, and I can't see what is inside the player model.
I can see that leaderstats is in there,but not where hit.Parent would be, so I can't adjust myself, does anybody know how I could do this? |
|
|
Could you show us more of the script and explain the hierarchical order of the objects?. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
local player = Game.Players:GetPlayerFromCharacter(hit.Parent)
if player then --make sure it was a player, to keep from erroring
player.leaderstats.Money.Value = 0
end |
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
Yeah.
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Value = 250
money.Name = "Money"
when a player joins they are given the leaderstats model.
SCRIPT 2: the one throwing the errors
function Touched(hit)if hit and hit.Parent and hit.Parent:findFirstChild("Humanoid") then
if hit.Parent.Name == sp.Parent.Parent.Parent.Owner.Boss.Value
then
hit.Parent.leaderstats.money.Value = hit.Parent.Parent.leaderstats.Money.Value+sp.Parent.Collect
end
end
end
script.Parent.Touched:connect(Touched) |
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
btw the leaderstats is fine, its just picking up money from a block that isn't working. |
|
|
What kind of "Object" is "Collect"?. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
script.Parent.Touched:connect(function(hit)
local player = Game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local Money = player:WaitForChild("leaderstats"):WaitForChild("Money")
Money.Value = Money.Value + 10
end
end) |
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
Collect is an Integer. |
|
|
Then, try using something such as,
sp.Parent.Collect.Value
If that's what you meant. |
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
Hey, uh, 128 I edited your code, and it is still not working.
hit.Parent.leaderstats.money.Value
Isn't the right nav, I can't even see what is inside the player area because it is all hidden...
ffs. |
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
@anon sorry, it was off the page and I didn't copy it X_X
|
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
Okay, fixed it, thanks for the help Anon and 128 :)
I owe you both. |
|