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

Can you make a spawn button that can spawn cars ive inserted from the toolbox?

Asked by 4 years ago

Can you make a spawn button that can spawn cars ive inserted from the toolbox? ive tried to to follow diffrent instruction on how to regen and how to spawn parts, but i have found nothing on inserted objects. is it even possible?

sorry, im very very new at scripting

0
This is a request. requests are against scriptinghelpers rules. I will do it though Dudeguy90539 36 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Again, this website is not meant for requests.

Put this code inside a part, and put your model in ServerStorage.

local TIMEOUT = false --plz dont change this
local RECHARGE = 3 --Time it takes for the button to be used again
local CAR_NAME = "car" --Name of the car model goes here. (Put the model in serverStorage)
--Keep in mind that if your car is a model (any functional car most likely is) then you will need to set its PrimaryPart property.


script.Parent.Touched:Connect(function(t)
    if t.Parent:IsA("Model") then
        if t.Parent:FindFirstChildOfClass("Humanoid") then

            local p = game.ServerStorage:FindFirstChild(CAR_NAME)
            if p then
                if TIMEOUT == false then
                    TIMEOUT = true

                    local c = p:Clone()
                    c.Parent = game.Workspace
                    if c:IsA("Model") then
                        c:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position - script.Parent.CFrame.LookVector*-1)) --Put model behind the button
                    else
                        c.Position = script.Parent.Position - script.Parent.CFrame.LookVector*-7 -- Put part behind the button
                    end
                    local oldColor = script.Parent.Color
                    script.Parent.Color = Color3.new(1,0,0) -- Turn red while it is not in use
                    wait(RECHARGE)
                    TIMEOUT = false
                    script.Parent.Color = oldColor
                end
            end

        end
    end
end)

In the future, please do not post requests (asking people to write scripts or make models) and ask for help (e.g - how do i do this, what is wrong with this segment of code)

Ad

Answer this question