What have I done wrong in my vehicle spawner script?
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.)
01 | local ADFBike = game.ReplicatedStorage [ "ADF Bike" ] |
02 | local Tool = script.Parent |
05 | for _,i in pairs (m:GetChildren()) do |
06 | if i:IsA( "BasePart" ) then |
15 | Tool.Equipped:connect( function (Mouse) |
16 | Mouse.Button 1 Up:connect( function () |
18 | local MTar = Mouse.Target |
19 | if MTar.Name = = "Vehicle Pad" then |
21 | local NewBike = ADFBike:Clone() |
23 | NewBike.Parent = game.Workspace |
25 | NewBike:MoveTo(Mouse.Target.Position + Vector 3. new( 0 , 5 , 0 )) |
29 | script.Parent:Destroy() |