Script Error support

My script won’t work. Can anybody tell me why? (It’s for selling strength to get cash in a sim)
Script: (I don’t know how to do it like other people do it)

local part = script.Parent
part.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats.Cash
local selling = leaderstats.Strength
if selling.Value >= 0 then
money.Value = money.Value + selling.Value*1
selling.Value = 0
end
end
end
end)

local part = script.Parent
part.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChild(“Humanoid”)
    if h then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            local leaderstats = player:WaitForChild(“leaderstats”)
            local money = leaderstats.Cash
            local selling = leaderstats.Strength
            if selling.Value >= 0 then
                money.Value += selling.Value
                selling.Value = 0
            end
        end
    end
end)

ok I made it easier to read so I can look at it

so what exactly isn’t working?

When I get strength then try and step on the sell part, I don’t get any coins.

local part = script.Parent
local debounce = false
part.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player and debounce == false then
        debounce = true
        local leaderstats = player:WaitForChild(“leaderstats”)
        local money = leaderstats.Cash
        local selling = leaderstats.Strength
        if selling.Value >= 0 then
            money.Value += selling.Value
            selling.Value = 0
        end
        debounce = false
    end
end)

I made the script better, also the problem could be that you don’t have a leaderstats

I have leaderstats, all the scripts that apply, I have.

any errors in output? or script analysis?

No script errors are shown. (don’t mind this)

can you add prints in your code and see how far it gets?
that will help

one problem could be that you are changing values via the client and you are checking them on the server

wait it says syntax error: Expected ‘)’ ( to close ‘(’ at line 3), got < eof > (Using your script.)


I clearly added a “)”
btw that’s a screenshot

Where is this script in hierarchy (Explorer)

it’s in “SellPart”
(character limit)

Local script or normal script?

I thought that was obvious with the first line in the code :joy:

1 Like

normal script
(character limit)

are you changing leaderstats values in local scripts?

Could you send any screenshot? It can help

I don’t find the code to be wrong so I think this has to be it

if that isn’t the problem then this is hard since he have little info

alright just a second
(character limit)