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

My tank goes haywire when I attach my turret to it?

Asked by
Nep_Ryker 131
6 years ago
Edited 6 years ago

So I have a turret that would always point at the player's mouse. I want to attach it to a car, but whenever I attach it together using Hinge, I test, the car and the turret would go flying crazy and look very glitchy. My goal is to attach the turret onto a car, without making it go haywire of course. Anyone know a solution to this? Thanks!

This is the script that makes the turret follow the player's mouse.

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function()
        repeat wait() until game.Workspace.TestingCannon.SpinningPart.Base
        while true do
            local pos
            local m = p:GetMouse()
            local t = m.Hit
            if t then
                pos = t
                local base = game.Workspace.TestingCannon.SpinningPart:WaitForChild("Base") 
                local h = p.Character:WaitForChild("Head")
                base.CFrame = CFrame.new(base.Position,Vector3.new(t.X,t.Y,t.Z))
                --tor["Neck"].C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)
            end
            wait()
        end
    end)
end)

Base is basically the turret.

Sorry if this has nothing to do with scripting.

0
Show us the script perhaps? tantec 305 — 6y

Answer this question