Help needed: When part cloned with script in it script doesn't work anymore

Hey,
Me and my friend are trying to make a quest system for the Christmas update on my game and we have worked all day trying to fix but still nothing not even an error is showing up, When we clonde a part with a script, the same script doesn’t work anymore, here is the code:

local cost = 100000
local prompt = script.Parent
local gift = script.Parent.Parent.Gift
local places = game.Workspace.Places:GetChildren()

prompt.Triggered:Connect(function(player)
    if player.leaderstats.Money.Value >= cost then
        player.leaderstats.Money.Value -= cost

        player.PlayerGui["Gift Collected"].Enabled = true

        local index = 0

        repeat wait()
            local place = places[math.random(1,#places)]
            local cGift = gift:Clone()
            cGift.Parent = game.Workspace
            cGift.Position = place.Position
            cGift.CanBeTriggerdBy.Value = player.Name

            index += 1
        until index == 5
    end
end)

Please help bc we wanne release the update today.

if player.leaderstats.Money.Value >= cost then
        player.leaderstats.Money.Value -= cost

Is the players money still higher/equal to the cost afterwards?

no, its 0 because it takes away money from the player

Try setting the players money 2 or 3 times higher than the cost.(For testing of course)
If that solves it then your script is fine you just didn’t have enough money to pass the if check.

1 Like

Didn’t work :confused: still thx for the help

Are there any errors in the output?

no but i we fixed it by debugging and found that line 16 was something wrong but we fixed it, still thx guys for the help