[solved]why is ray not casting while aiming?
Asked by
1 year ago Edited 1 year ago
So, basically im making a sniper game, but i have one big problem. if i dont aim everything seems like normal and the serversided fastcast script works perfectly fine. But if im aiming, the caster doesnt Fire but the remoteevent is working. Any help and ideas are appreciated.
Please note that i am using a scope GUI to represent aiming.
Client:
01 | local mousePos = mouse.Hit.Position |
03 | for i, v in pairs (game.ReplicatedStorage.Instances.VModel.Value:GetDescendants()) do |
04 | table.insert(Table, v) |
06 | game.ReplicatedStorage.Events.FireEvent:FireServer(framework.viewmodel.FirePart.Position, mousePos, framework.module.velocity, Table) |
07 | framework.module.ammo - = 1 |
11 | until IsAiming = = false |
13 | if framework.module.ammo ~ = 0 then |
15 | game.ReplicatedStorage.Events.BoltEvent:FireServer() |
17 | wait(boltAnimTrack.Length + 0.25 ) |
Server:
01 | game.ReplicatedStorage.Events.FireEvent.OnServerEvent:Connect( function (Traveledplayer, firePartPos, mousePos, velocity, ITable) |
02 | if Traveledplayer.Character then |
04 | local sound = Traveledplayer.Character.UpperTorso:FindFirstChild( "Fire" ) |
07 | Player = Traveledplayer |
09 | castParams.FilterType = Enum.RaycastFilterType.Blacklist |
10 | for i, v in pairs (Traveledplayer.Character:GetDescendants()) do |
11 | table.insert(ITable, v) |
13 | castParams.FilterDescendantsInstances = ITable |
14 | castParams.IgnoreWater = true |
16 | castBeh.RaycastParams = castParams |
17 | castBeh.Acceleration = Vector 3. new( 0 , -workspace.Gravity, 0 ) |
18 | castBeh.AutoIgnoreContainer = false |
20 | local origin = firePartPos |
21 | local direction = mousePos - origin |
23 | caster:Fire(origin, direction, velocity, castBeh) |