CFrame.LookVector*speed is not working. Why?
Asked by
5 years ago Edited 5 years ago
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:-
01 | ** local TurretGui = script.Parent |
03 | local Frame = TurretGui:WaitForChild( "Frame" ) |
04 | local Button = Frame:WaitForChild( "FireButton" ) |
06 | local Seat = workspace:WaitForChild( "Turret" ):WaitForChild( "MainModel" ):WaitForChild( "Seat" ) |
08 | local player = game.Players.LocalPlayer |
09 | local Camera = game.Workspace.CurrentCamera |
10 | local IncrementBox = Frame.IncrementBox |
14 | Seat:GetPropertyChangedSignal( "Occupant" ):Connect( function () |
15 | local humanoid = Seat.Occupant |
18 | local occupant = game.Players:GetPlayerFromCharacter(humanoid.Parent) |
19 | if occupant = = player then |
21 | local UserInputService = game:GetService( "UserInputService" ) |
22 | local MainModel = game.Workspace.Turret.MainModel |
23 | Camera.CameraType = Enum.CameraType.Attach |
25 | UserInputService.InputBegan:Connect( function (input) |
27 | if input.KeyCode = = Enum.KeyCode.H then |
28 | local NewCframeRt = MainModel:SetPrimaryPartCFrame(MainModel.PrimaryPart.CFrame * CFrame.Angles( 0 , -(IncrementBox.Text) , 0 )) |
30 | local CFrameNameRt = MainModel:GetPrimaryPartCFrame() |
32 | game.ReplicatedStorage.TurretRemoteEvent.RemoteEventRt:FireServer(CFrameNameRt) |
41 | Camera.CameraType = Enum.CameraType.Follow |
and then the normal script in server script service:-
01 | **game.Players.PlayerAdded:Connect( function (player) |
05 | local Gui = player.PlayerGui.TurretGui |
07 | local Frame = Gui.Frame |
08 | local button = Frame.FireButton |
09 | local Sound = game.Workspace.Turret.MortarSound |
11 | button.MouseButton 1 Click:Connect( function () |
13 | local Nozzel = game.Workspace.Turret.MainModel.FireNozzel |
14 | local firePart = game.ServerStorage.FirePart:Clone() |
15 | firePart.Parent = game.Workspace |
16 | firePart.Position = game.Workspace.Turret.Storage.Position |
20 | game.Workspace.Turret.MainModel.FireNozzel.CanCollide = false |
21 | firePart.Position = game.Workspace.Turret.MainModel.FireNozzel.Position |
22 | game.ReplicatedStorage.TurretRemoteEvent.RemoteEventRt.OnServerEvent:Connect( function (player, NewCframeRt) |
25 | firePart.Velocity = Nozzel.CFrame.LookVector*( 150 ) |
28 | game.Workspace.Turret.MainModel.FireNozzel.CanCollide = true |
34 | firePart.Touched:Connect( function (hit) |
35 | local CharDescendants = player.Character:GetChildren() |
36 | for i,v in pairs (CharDescendants) do |
37 | if hit.Parent.Name = = v.Name then |
38 | hit.Parent.Parent.Humanoid:TakeDamage( 30 ) |
please someone help what do i do...