Hello, i want to have a tank with rotating turret. I tried couple solutions but it didn’t help me.
The solutions i tried:
-
I tried with hinge and it did work pretty well. Until I rode the tank. It did not attach properly to the tank and when I tried to rotate the turret while driving, the turret just popped off.
-
I tried with weld and when i tried to rotate turret, all the parts of tank rotated too
-
I tried with c0 of weld and when i tried to rotate it, the turret got inside the tank main body as shown in the image
The scripts are:
- Inside tank script:
event = game.ReplicatedStorage.d
kule = script.Parent.Taret.Kule
event.OnServerEvent:Connect(function(p, m)
local _, rY, _ = CFrame.new(kule.CFrame.p, m):ToOrientation()
local rX, _, rZ = kule.CFrame:ToOrientation()
kule.CFrame = CFrame.new(kule.CFrame.p) * CFrame.fromOrientation(rX, rY, rZ)
end)
- Inside player script:
p = game.Players.LocalPlayer
mouse = p:GetMouse()
event = game.ReplicatedStorage.d
mouse.Button1Down:Connect(function()
event:FireServer(mouse.Hit.Position)
end)