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

Why won't my tycoon script function properly? It doesn't make the items appear

Asked by
BashGuy10 384 Moderation Voter
5 years ago
Edited 5 years ago

Hi peoples of the internet, after trying to make a tycoon(and failing to), i decided to do a rewrite of my system, but it wont work! No errors are produced, the lines i think are causing the problem are Line 20 and Line 53, anybody out there know how to fix this?

What is happening: I am trying to put a item into a folder in workspace, put it won't work dependency is all fine and stuff

Tycoon setup: https://gyazo.com/2d1ba2afb80da7a1a799672f62e18a96

If you need anything else, ask.

(i used a few parts of the script from a tutorial, like dependency stuff)

My script:

local tycoon = script.Parent.Parent
local bought = tycoon.Bought
local buyables = tycoon.Buyables
local buttons = tycoon.Buttons

local objects = {}

local function ensureownerhit(plr) -- ignore this please

end


for i, v in pairs(buttons:GetChildren()) do
    if v then
        if v.Head then

            local objectthing = buyables:WaitForChild(v.Object.Value)

            if objectthing then
                objects[objectthing.Name] = objectthing:Clone()

                objectthing:Destroy()



                if v:FindFirstChild("Dependency") then
                    coroutine.resume(coroutine.create(function()

                        v.Head.CanCollide = false
                        v.Head.Transparency = 1
                        v.Part.CanCollide = false
                        v.Part.Transparency = 1

                        if bought:WaitForChild(v.Dependency.Value) then

                            v.Head.CanCollide = true
                            v.Head.Transparency = 0
                            v.Part.CanCollide = true
                            v.Part.Transparency = 0

                        end

                    end))
                end

                local debounce = false

                v.Head.Touched:Connect(function(hit)
                    if not debounce then
                        debounce = true

                        if v.Head.CanCollide then
                            objects[v.Object.Value] = bought

                            v:Destroy()
                        end

                        debounce = false
                    end
                end)
            end
        end
    end
end

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

You need to set the parent for objects[objectthing.Name] to the workspace or wherever you want to put it.

0
Of course its the simple things that get me :p, i need to go get some coffee im on low power lol BashGuy10 384 — 5y
0
it's not simple. it can be hard to catch. i only knew it because i've messed up like that so many times. royaltoe 5144 — 5y
Ad

Answer this question