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

Strength is not a valid member of IntValue "Players.ghgg471.leaderstats.Strength" how to fix?

Asked by 3 years ago

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)
0
It's okay we're here to help people with errors. some people request for scripts which is not the purpose of this website MarkedTomato 810 — 3y
0
thx ghgg471 8 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

0
thx ghgg471 8 — 3y
0
im so dumb ghgg471 8 — 3y
Ad

Answer this question