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)
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)