There is no point is what I am trying to say. Doing it on the client can reduce memory leaks and just calculate the operations on the CPU. It may reduce FPS, but it is better than the whole server shutting down.
Oh, alright. Thanks for letting me know
So the best solution to this problem is just doing all of these on the client.
It’s best to do this to reduce memory leaks and lag.
It will also be smoother when you do it on the client. So it doesn’t look like you have low FPS.
How do i check if they moved the correct distance though? Could you give an example please?
First, you need RemoteEvent
s that the client fires when they start and finish vaulting. Then, you need to check the distance between when they started and finished to make sure it’s in an acceptable range:
-- The maximum distance they can move with a vault
-- Tune this to your game
local MAX_VAULT_DISTANCE = 15
local PlayerVaultingPositions = {}
Remotes.PlayerStartedVaulting.OnServerEvent:Connect(function(Player)
-- Keep track of where someone was when they started vaulting
PlayerVaultingPositions[Player] = Player.Character.PrimaryPart.CFrame
end)
Remotes.PlayerFinishedVaulting.OnServerEvent:Connect(function(Player)
local CurrentPosition = Player.Character.PrimaryPart.Position
-- Calculate how far they moved when vaulting
local Distance = (PlayerVaultingPositions[Player].Position - CurrentPosition).Magnitude
if Distance > MAX_VAULT_DISTANCE then
-- Reset them back to the place where they started vaulting
Player.Character:PivotTo(PlayerVaultingPositions[Player])
-- Temporarily take control away from the player
Player.Character.PrimaryPart:SetNetworkOwner(nil)
task.wait(2)
Player.Character.PrimaryPart:SetNetworkOwner(Player)
end
end)
And, of course, you will need to fire the remote event PlayerStartedVaulting
when the player presses the key to vault, and fire the remote event PlayerFinishedVaulted
when you stop applying velocity to the player at the end of the vault.
So,exploiters cannot stop the events from sending?
You could also make sure that players don’t move too far in one second whether or not they are vaulting. Roblox has an article on this:
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.