i tried to make this code give me 1 strength when i right click using a tool and a lot of web surfing
local tool = script.Parent local Player = tool.Parent.Parent local leaderstat = Player.leaderstats.Strength tool.Activated:Connect(function() leaderstat.Strength.Value = leaderstat.Strength.Value + 1 end)
this some how worked
local part = script.Parent local click = part.ClickDetector local function explode(Player) Player.leaderstats.Strength.Value = Player.leaderstats.Strength.Value -1 local explosion = Instance.new("Explosion") explosion.Parent = part explosion.Position = part.Position end click.MouseClick:Connect(explode)
this explodes a block on touch but dosent destroy it and gives -1 point instead of destroying i dont want it to destry pls answer the above one here how i made the strength leader stats local function
local function OnPlayerJoin(Player) local leaderstats = Instance.new('Folder') leaderstats.Name = "leaderstats" leaderstats.Parent = Player local Strength = Instance.new('IntValue') Strength.Name = 'Strength' Strength.Value = 1 Strength.Parent = leaderstats end game.Players.PlayerAdded:Connect(OnPlayerJoin)
In line 3 you referred leaderstats with strength. So just remove the 'Strength' in the first script at the end of line 3 and nothing else. like this:
local leaderstat = Player.leaderstats -- and not local leaderstat = Player.leaderstats.Strength -- you're referring to the integer value AKA int value
also if you get an error like this you're referring to a child of an instance that doesn't exist