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

Fixing the joints of a vehicle spawner tool?

Asked by 6 years ago

Hello I have a tool that when you click anywhere on the ground, it spawns a model. Problem: The car is spawned, but when I drive it, the wheels do not turn left or right.

Script:

bin = script.Parent

function onButton1Down(mouse)

    local model = bin.Car:clone()
    model.Parent = game.Workspace
    model:MakeJoints()
    model:MoveTo(mouse.hit.p)

end

function onSelected(mouse)
    mouse.Icon = "rbxasset://textures\\GunCursor.png"
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end



bin.Selected:connect(onSelected)

How do I fix it? Thanks!

1 answer

Log in to vote
0
Answered by 6 years ago

Make local script in StarterPack

Here's an example that maybe you could use

    local Part =game.Workspace.Model
    playerMouse = game.Players.LocalPlayer:GetMouse()
    playerMouse.Button1Down:connect(function(Hit)
        local Part2 = Part:Clone()
        Part2.Parent = game.Workspace
        Part2:MakeJoints()
        local x = playerMouse.Hit.X
        local y = playerMouse.Hit.Y
        local z = playerMouse.Hit.Z
        Part:MoveTo(Vector3.new(x,y,z))
    end)

0
Ok it works, but I have to re-enter the car 3-4 times before the wheels start working. How do I fix this? Thx! BADABOO2016 3 — 6y
0
Actually your script does do anything. sorry BADABOO2016 3 — 6y
Ad

Answer this question