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

why doesn't my sell script work?its supposed to add 2 int values together

Asked by
seikkatsu 110
4 years ago
local d = 0
script.Parent.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    local p = game.Players:GetPlayerFromCharacter(hit.Parent)
    local stats = p:FindFirstChild("leaderstats")
    local str = stats.Strenght
    local coins = stats.Coins
    if h and d == 0 then
        coins.Value = 0 + str.Value

    end
end)

it does not add to the coins value any help is apriciated

1 answer

Log in to vote
1
Answered by
VitroxVox 884 Moderation Voter
4 years ago

Hello, i think i found your problem. You're not adding the coins value so you're just adding the "str" value to a 0 and making that the coin, so the current coin that the user would have it would be gone, here's a fix:

local d = 0
script.Parent.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    local p = game.Players:GetPlayerFromCharacter(hit.Parent)
    local stats = p:FindFirstChild("leaderstats")
    local str = stats.Strenght
    local coins = stats.Coins
    if h and d == 0 then
        coins.Value = coins.Value + str.Value

    end
end)

if it worked please accept, thank you.

0
it doesn't.. seikkatsu 110 — 4y
Ad

Answer this question