So I was scripting a game where you can throw items around… The problem that I was having was when I instantiated a projectile it would lag for a second and then it will start moving
This only started happening after I started rendering on the server-side. I already tried using something call PCache and I don’t really want to get into restarting my code for FastCast. Is there any other way to fix this?
Here is an example:
By the way don’t use instance .new with a second arguement.
I believe you need to set the properties first then parent it into the workspace since I believe the delay is due to the delay in setting the velocity of the projectile.
- looks (material, color, size, etc.)
- the light
- set network owner to the client who fired it, not “nil”
- physics (cancollide, location, velocity)
- parent
You can remove the BodyVelocity part and do something like…
local Speed = 5
local Connection
Connection = RunService.Stepped:Connect(function()
if not Part then -- Stops moving and disconnects if it doesn't exist anymore
Connection:Disconnect()
end
local ProjectileRay = Ray.new(Part.Position, Part.CFrame.LookVector * Speed)
local Hit,Position = Workspace:FindPartOnRay(ProjectileRay, Character)
Part.Position = Part.Position + Part.CFrame.LookVector * Speed
if Hit then
-- Do collision logic
Connection:Disconnect() -- Stops moving as it's collided by now
end
end)
It might be useful if it’s related to what I’m seeing. You’d need to adapt it to the way that you’re working on tbh.