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

Make a Tycoon Dropper drop models?

Asked by 8 years ago

I wanted to know if i could create a tycoon dropper and make it drop a model? i built a model and i wanted to drop it, like it could be in server storage and it would be cloned?

wait(2)
workspace:WaitForChild("PartStorage")

while true do
    wait(2.5) -- How long in between drops
    local part = Instance.new("Part",workspace.PartStorage)
    part.BrickColor=script.Parent.Parent.Parent.DropColor.Value
    part.Material=script.Parent.Parent.Parent.MaterialValue.Value
    local cash = Instance.new("IntValue",part)
    cash.Name = "Cash"
    cash.Value = 10 -- How much the drops are worth
    part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.6,0)
    part.FormFactor = "Custom"
    part.Size=Vector3.new(1.4, 1.4, 1.4) -- Size of the drops
    part.TopSurface = "Smooth"
    part.BottomSurface = "Smooth"
    game.Debris:AddItem(part,20) -- How long until the drops expire
end
0
Use a weld script inside the model and clone the model from that script example: game.ServerStorage.MODELNAME:clone etc... minetrackmania 186 — 8y
0
I'm pretty new, do you think you could show me where i'd add it, and stuff? iiEffects 25 — 8y

1 answer

Log in to vote
0
Answered by
AZDev 590 Moderation Voter
8 years ago

First you model needs to be welded. Depending on your model's complexity you can do this manually or you may want to do it with a script.

-- Weld script by crazyman32
-- This goes in a script, the script goes in model. 

--IMPORTANT: If your model is in ServerStorage or ReplicatedStorage you need to pre-weld the model. 

function weld()
    local parts,last = {}
    local function scan(parent)
        for _,v in pairs(parent:GetChildren()) do
            if (v:IsA("BasePart")) then
                if (last) then
                    local w = Instance.new("Weld")
                    w.Name = ("%s_Weld"):format(v.Name)
                    w.Part0,w.Part1 = last,v
                    w.C0 = last.CFrame:inverse()
                    w.C1 = v.CFrame:inverse()
                    w.Parent = last
                end
                last = v
                table.insert(parts,v)
            end
            scan(v)
        end
    end
    scan(script.Parent)
    for _,v in pairs(parts) do
        v.Anchored = false
    end
end

weld()
script:Remove()

After you've welded your model, Set the primary part of you model. The primary part should probably be in the center top of your model.

Now simply clone the model, set parent, then use set the primary parts CFrame to the drop CFrame.

You can use the wiki to learn about everything in this answer. This wiki link will help with a lot of what you'll need. API:Class/Model

0
I'll leave the rest up to you. AZDev 590 — 8y
0
For a dropper, I would think for the primary part, it would be best to use the head. :P FrostTaco 90 — 8y
0
iiEffects made no mention of a head. AZDev 590 — 8y
Ad

Answer this question