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

Im making a tycoon game and the dropper part doesnt destroy nor give cash value, how do i fix it?

Asked by 1 year ago

Ive looked thru the code myself and everything looked fine but the script isnt working

local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

script.Parent.Touched:Connect(function(hit)
    if hit.Name == "Part" and hit:FindFirstChild("CashValue") then
        CashValue.Value += hit:FindFirstChild("CashValue").Value
        hit:Destroy()
    end
end)
0
is this a local script and are you sure that CashValue can be found and is the part name Part? Puppynniko 1059 — 1y
0
it is not a localscript and the parts name is part CookieTheElfy 0 — 1y
0
where is this script? Puppynniko 1059 — 1y
0
MainItems Folder CookieTheElfy 0 — 1y
View all comments (3 more)
0
Hey there puppy, the script you recommended didnt work. Can you think of something else? CookieTheElfy 0 — 1y
0
then are you spawning the block in a local script? Puppynniko 1059 — 1y
0
no CookieTheElfy 0 — 1y

1 answer

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
1 year ago
Edited 1 year ago

In the part where the parts goes in, this script should work

local CashValue = workspace.Tycoon.CashValue
script.Parent.Touched:Connect(function(hit)
       if hit:FindFirstChild("CashValue") then --make sure its a part to sell idk how to say it lol
               local Value = hit:FindFirstChild("CashValue").Value
               CashValue.Value += Value --assuming CashValue is in workspace
               hit:Destroy()
        end
end)
0
That script didnt work CookieTheElfy 0 — 1y
Ad

Answer this question