In my last post I discussed my confusion for my part always being off center of the bullet during the turrets traversal.
Whilst this did fix the issue, I came across the problem of bullet delay but I decided I would use the remote event to send a message across all clients. However I get the same delay I had with CFrame where it’s once again misaligned with the canon.
What can I do to fix the latency on the client’s bullet?
Local Script:
UIS.InputBegan:Connect(function(input)
if(is_gunner) then
if (input.KeyCode == AIM) then --Enables / Disables gunner sight
gunner_sight = not gunner_sight
if(not gunner_sight) then
game.Workspace.Camera.CameraSubject = game.Workspace[gun_ownership].Camera
game.Workspace.Camera.CameraType = Enum.CameraType.Attach
end
end
if (input.UserInputType == FIRE) then --FIRING SCRIPT HERE
local CFRAME_1
local CFRAME_2
firing = true
local fire_cooldown = (60 / gun_firerate)
while (firing) do
CFRAME_1 = workspace[gun_ownership].M_Round_Pos.CFrame
if (double_barrel) then
CFRAME_2 = workspace[gun_ownership].L_Round_Pos.CFrame
end
game.ReplicatedStorage.GunControls:FireServer(FIRE, nil, gun_ownership, CFRAME_1, CFRAME_2)
task.wait(fire_cooldown)
end
end
--[Remaining Script is irrelevant]
end
end)
game.ReplicatedStorage.GunControls.OnClientEvent:Connect(function(MAIN_ROUND) --Makes bullet for client
local bullet_1 = workspace[gun_ownership].Bullet:Clone()
bullet_1.Parent = workspace[gun_ownership]
bullet_1.Anchored = false
bullet_1.CFrame = MAIN_ROUND
bullet_1.Transparency = 0
end)
Server Script:
game.ReplicatedStorage.GunControls.OnServerEvent:Connect(function(plr, control, action, model, MAIN_ROUND, SECONDARY_ROUND)
if (model == script.Parent.Name) then --Makes sure message is sent to proper turret
if (control == FIRE) then
local bullet_1--Ignore
local bullet_2--Ignore
game.ReplicatedStorage.GunControls:FireAllClients(MAIN_ROUND) --Makes bullet client sided
--[Remaining Script is irrelevant]