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

LocalHumanoid script troubles please help!!!?

Asked by 8 years ago

Here is the script i am trying to write.

local Humanoid = script.Parent.Humanoid 
function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
if tag ~= nil then 
if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
if Leaderstats ~= nil then 
Leaderstats.Robux.Value = Leaderstats.Robux.Value + math.random(1,5)
wait(0.1)
script:remove()
end 
end 
end 
end 
Humanoid.Died:connect(PwntX_X) 

Does anyone know why it is not working??? Please leave an answer ;)

2 answers

Log in to vote
1
Answered by 8 years ago

Leaderstats are stored inside the player, not the humanoid. I'll fix the script, just use this instead.

local Humanoid = script.Parent.Humanoid 
function PwntX_X() 
local tag = Humanoid:FindFirstChild("creator") 
if tag ~= nil then 
if tag.Value ~= nil then 
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local Leaderstats = player:WaitForChild("leaderstats")
if Leaderstats ~= nil then 
Leaderstats.Robux.Value = Leaderstats.Robux.Value + math.random(1,5)
wait(0.1)
script:Destroy()
end 
end 
end 
end 
Humanoid.Died:connect(PwntX_X) 


0
Also assuming this script is in The player's Character, which is highly unlikely ChemicalHex 979 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

Your trying to find leaderstats in a Humanoid try using game.players.LocalPlayers.leaderstats.Robux.Value instead of humanoid. But also does it show any error in the output?

Answer this question