What do you want to achieve? I want to make a movement system where I get an extra double jump when I pick up a green arrow power up, which is spinning in place.
What is the issue? My code works fine, but when running the game my power up has extreme network lag, making it unusable.
Here’s what it looks like when running the game from Roblox (too slow to react, spinning animation is laggy:
And here’s what it looks like in Roblox Studio (intended):
- What solutions have you tried so far? I haven’t been able to find a solution to try, but I did find a few discussions out there that mention that too many events being passed from the server to the client may be an issue. I do have a RemoteEvent tied to when the player touches the hitbox of the powerup, but it should only be firing when something other than the arrow model is touching it (I set the collision group of the arrow model to 1, while leaving everything else at 0)
Here’s the code in every part of the game that interacts with this powerup.
The invisible hitbox of the power up:
wait(3) local hitbox = script.Parent local boostModel = hitbox.Parent local arrow = boostModel.Arrow local arrowColor = arrow.Color local arrowTrans = arrow.Transparency local rs = game:GetService("ReplicatedStorage") local players = game:GetService("Players") local BoostServerEvent = rs:WaitForChild("TouchedJumpBoost") local isEnabled = true local function PowerUpCooldown() isEnabled = false print("power up disabled") arrow.Color = Color3.new(0.584314, 0.584314, 0.584314) arrow.Transparency = 0.7 arrow.ParticleEmitter.Enabled = false wait(5) isEnabled = true print("power up enabled") arrow.Color = arrowColor arrow.Transparency = arrowTrans arrow.ParticleEmitter.Enabled = true end hitbox.Touched:Connect(function(hit) if hit.Parent.Humanoid and isEnabled == true then local player = players:GetPlayerFromCharacter(hit.Parent) BoostServerEvent:FireClient(player) PowerUpCooldown() end end)
The part of the movement script of the player which handles double jumping (It is a LocalScript in StarterPlayer):
local function onPowerUp() hasJumped = false canJumpAgain = true end BoostServerEvent.OnClientEvent:Connect(onPowerUp)
Lastly, the script inside the Arrow model that makes it rotate, just in case that has something to do with it
local p = script.Parent --Rotate local cf = CFrame.Angles(0,0.03,0) while true do wait(0.001) p.CFrame = p.CFrame * cf end --
I would really love some ideas here. My internet is pretty good so I don’t expect there to be issues in that regard (nor do I think I would have the same problem if I did have bad internet). Has anyone else experienced this issue, or know how to fix it? Thanks!