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

Why the Part not give a Cash and not destroy at PartCollector?

Asked by 3 years ago

The Problem is Why the Part(from the Dropper)not Destroy and not give a cash if the part Destroy at the PartCollector?

script.Parent.Parent.PartCollector.Touched:Connect(function(Part)
    if Part.Touched(function(Player)
            game.Workspace.Part.Destroy:(function(Part)
                if game.Workspace.Part.Destroy:() then
                    stats.Cash.Value + 10
                end
        end)
    end
end)

Fix what's wrong with this script, if you can make it :)

Thanks :)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You cannot use an if statement for a function in lines 2 and 4

the destroy function cannot be used like that, either, in line 3(i don't think)

Here is a fixed script:

script.Parent.Parent.PartCollector.Touched:Connect(function(Part)
    Part.Touched:Connect(function(Player)
        game.Workspace.Part:Destroy()
        stats.Cash.Value = stats.Cash.Value + 10 -- you cannot say "stats.Cash.Value + 10"
    end)
end)

If statements: https://education.roblox.com/en-us/resources/if-then-statements

Destroy: https://developer.roblox.com/en-us/api-reference/function/Instance/Destroy

Operators: https://developer.roblox.com/en-us/articles/Operators

Hope this helps

1
Very Thanks So Much ^w^ RizkySugihartoYT 36 — 3y
0
ehh, but why i not get the cash? ;-; RizkySugihartoYT 36 — 3y
0
Sorry for the late reply, have you specified what "stats" is in later lines? If not, you can use game.Players:GetPlayerFromCharacter (the player variable) and access the stats from there Omq_ItzJasmin 666 — 3y
Ad

Answer this question