Hello. I am making a gun for a spaceship with fastcast. Spaceships move quickly, and I have discovered that when moving at high enough speeds, the prop bullets that fastcast allows you to use lag behind on the client a little. I know this is only an issue for the client, because I did a 1 player test, and saw that it looked fine on the server. I am now trying to figure out how to properly sync the bullet’s CFrame between server and client.
This is my code for managing the bullet CFrame on the server.
local function onLengthChanged(_, lastPoint, direction, length, _, b)
if b then
local bulletLength = b.Size.Z/2
local offset = CFrame.new(0, 0, -(length - bulletLength))
b.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
end
end
if im correct, it is always impossible to make the 2 in sync. id assume because the client REPLICATES the server, so like tagging along. my best guess would be handling it all on the server but it can be impactful. (thats all ik abt it i could be wrong but yea
It is all handled on the server. The only thing the client handles, is handling clicking the mouse to actually fire, and I don’t really have a choice for that considering how I coded the ship.
you can control the player clicking on the server
I don’t think so? The gun isn’t a tool, again, it’s on a spaceship.
its possible, just depends on the script to modify it to work on the server
Well how my handling works, the client manager for the spaceship will see when the mouse button is down. If it gets pushed down, it tells the server via remote event, and if it’s up, it also tells the server that it’s up. Simple remote event, and it tells the server if the mouse is being held in the process. I can’t really replicate code seeing when the mouse button is down directly on the server, unless it was a tool, with .Activated, which again, it is not.
-- Client
Mouse.Button1Down:Connect(function()
ButtonEvent:FireServer("Mouse1", true)
end)
Mouse.Button1Up:Connect(function()
ButtonEvent:FireServer("Mouse1", false)
end)
-- Server
-- In a RunService.Heartbeat loop.
if HoldingButtons["Mouse1"] then
ShootGuns()
end
Sorry to necropost, but did you ever solve this problem? Im having the same issue 4 years later…
2 Likes