hi guys! while i was working with a turret, i saw its bullet not go in the direction of my angle of turret. I'm using a Gui for shooting consisting of the local script:-
**local TurretGui = script.Parent
local Frame = TurretGui:WaitForChild("Frame")
local Button = Frame:WaitForChild("FireButton")
local Seat = workspace:WaitForChild("Turret"):WaitForChild("MainModel"):WaitForChild("Seat")
local player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local IncrementBox = Frame.IncrementBox
Frame.Visible = false
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local humanoid = Seat.Occupant
if humanoid then
local occupant = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if occupant == player then
Frame.Visible = true
local UserInputService = game:GetService("UserInputService")
local MainModel = game.Workspace.Turret.MainModel
Camera.CameraType = Enum.CameraType.Attach
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.H then
local NewCframeRt = MainModel:SetPrimaryPartCFrame(MainModel.PrimaryPart.CFrame * CFrame.Angles(0, -(IncrementBox.Text) , 0))
local CFrameNameRt = MainModel:GetPrimaryPartCFrame()
game.ReplicatedStorage.TurretRemoteEvent.RemoteEventRt:FireServer(CFrameNameRt)
print("Sent")
end
end)
end
else
Camera.CameraType = Enum.CameraType.Follow
Frame.Visible = false
end
end) **
and then the normal script in server script service:-
**game.Players.PlayerAdded:Connect(function(player)
wait(10)
local Gui = player.PlayerGui.TurretGui
print("GuiFound")
local Frame = Gui.Frame
local button = Frame.FireButton
local Sound = game.Workspace.Turret.MortarSound
button.MouseButton1Click:Connect(function()
local Nozzel = game.Workspace.Turret.MainModel.FireNozzel
local firePart = game.ServerStorage.FirePart:Clone()
firePart.Parent = game.Workspace
firePart.Position = game.Workspace.Turret.Storage.Position
wait(3)
game.Workspace.Turret.MainModel.FireNozzel.CanCollide = false
firePart.Position = game.Workspace.Turret.MainModel.FireNozzel.Position
game.ReplicatedStorage.TurretRemoteEvent.RemoteEventRt.OnServerEvent:Connect(function(player, NewCframeRt)
firePart.Velocity = Nozzel.CFrame.LookVector*(150) --this is the part i feel problem is
wait(5)
game.Workspace.Turret.MainModel.FireNozzel.CanCollide = true
end)
Sound:Play()
firePart.Touched:Connect(function(hit)
local CharDescendants = player.Character:GetChildren()
for i,v in pairs(CharDescendants) do
if hit.Parent.Name == v.Name then
hit.Parent.Parent.Humanoid:TakeDamage(30)
end
end
end)
wait(5)
firePart:Destroy()
end)
end)**
please someone help what do i do...
