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

What have I done wrong in my vehicle spawner script?

Asked by 10 years ago

Hi guys, I've been trying to get this code to work for 2 days now. This is what it's supposed to do:

1) When the left mouse button is clicked, and the tool is equipped, identify vehicle pad 2) Clone the bike in ReplicatedStorage(no, it's not a possibility that these parts fell off the map. I anchored all of them.) 3) Place the new bike on the pad 4) Unanchor the bike 5) Destroy itself.

Here's the code block: (yes, this is in a localscript.)

local ADFBike = game.ReplicatedStorage["ADF Bike"]
local Tool = script.Parent

function unanchor (m)
    for _,i in pairs (m:GetChildren()) do
        if i:IsA("BasePart") then
            i:MakeJoints()
            i.Anchored = false
        else
            unanchor(i)
        end
    end
end

Tool.Equipped:connect(function (Mouse)
    Mouse.Button1Up:connect(function ()
        print("Activated")
        local MTar = Mouse.Target
        if MTar.Name == "Vehicle Pad" then
            print("Determined")
            local NewBike = ADFBike:Clone()
            print("Cloned")
            NewBike.Parent = game.Workspace
            print("Parented")
            NewBike:MoveTo(Mouse.Target.Position + Vector3.new(0, 5, 0))
            print("Positioned")
            unanchor(NewBike)
            print("Unanchored")
            script.Parent:Destroy()
        end
    end)
end)
1
Which of those print statements is running? adark 5487 — 10y

1 answer

Log in to vote
0
Answered by
RM0d 305 Moderation Voter
10 years ago

local ADFBike = game.ReplicatedStorage["ADF Bike"] local Tool = script.Parent function unanchor (m) for _,i in pairs (m:GetChildren()) do if i:IsA("BasePart") then i:MakeJoints() i.Anchored = false else unanchor(i) end end end Tool.Equipped:connect(function (Mouse) Mouse.Button1Up:connect(function () print("Activated") local MTar = Mouse.Target if MTar.Name == "Vehicle Pad" then print("Determined") local NewBike = ADFBike:Clone() NewBike:MakeJoints() print("Cloned") NewBike.Parent = game.Workspace print("Parented") NewBike:MoveTo(Mouse.Target.Position + Vector3.new(0, 5, 0)) print("Positioned") unanchor(NewBike) print("Unanchored") NewBike:MakeJoints() script.Parent:Destroy() end end) end)
1
will add more later RM0d 305 — 10y
Ad

Answer this question