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

?I am trying to make a tool give you points on click but its not working, please help me

I am trying to make an item give you money when you click it but it is not working

local tool = script.Parent
local Player = tool.Parent.Parent
local pplayer = game.Players:GetPlayerFromCharacter(Player)
local leaderstat = pplayer.leaderstats.Money


tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
	leaderstat.Value = leaderstat.Value + 25
	end)
end)

I always get this error Players.Anothuoretta.Backpack.money.Handle.Script:4: attempt to index nil with 'leaderstats'

1 answer

local Player = tool.Parent.Parent

You're asking for the parent of the tool twice Which, if the tool is in the character, will lead to Workspace.

local Player = tool.Parent

This will return the player's character.

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