Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LocalHumanoid script troubles please help!!!?

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

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) 


1 comment

0

Also assuming this script is in The player's Character, which is highly unlikely

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?

This discussion is preserved as it was. New answers, comments, and votes are closed.