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

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

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

✓ Accepted answer

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.

1 comment

0

it doesn't..

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