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

My items won't destroy and i don't get any money, how do I do?

Asked by 3 years ago

I am making a fishing simulator where you get your fish in your inventory, but it won't delete my fish when I touch my sell part, and nor will it give me money(Coins) Btw this is a local script in my sell part.

Here is my code:

local plr = game.Players.LocalPlayer

local plrBackpack = plr.Backpack

local part = script.Parent

part.Touched:Connect(function(hit)

    local coinsValue = plr.leaderstats.Coins.Value

    if not hit:IsDescendantOf(plr.Character) then return end

    for _, Fish in pairs(plrBackpack:GetChildren()) do

        if Fish.Name == 'Faceless fish' then

            Fish:Destroy()

            coinsValue += 5

        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Local scripts do not run in Workspace.

Also, you should not be handling coins on the client.

0
That doesn't really help me, but I did not know the thing about local scripts Anderssc 22 — 3y
Ad

Answer this question