So I have this jump pad script that works really well in studio, but in-game it is very delayed, I am pretty sure it is because of lag, but How would I fix it?
This is the script:
I don’t know if it will help
local PlayerTouchingPart = false
local JumpBoostAmount = 50
script.Parent.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
PlayerTouchingPart = true
if Humanoid then
while PlayerTouchingPart == true do
Humanoid.JumpPower = 150
Humanoid.Jump = true
wait(0.2)
Humanoid.JumpPower = 50
wait(0.2)
end
end
end)
script.Parent.TouchEnded:Connect(function()
wait(0.5)
PlayerTouchingPart = false
end)
This is a video showing it(Sorry, I am using roblox’s video recorder):
The best way would be to run the script for the jump pads on the client. (On the player.)
That way the jump pads work as aspected, instant feedback without any delay.
You could put a NumberValue inside each pad if they have different levels of JumpPower.
I made this quick script for you to point you in the right direction:
local JumpPadFolderChildren = game.Workspace.JumpPads:GetChildren()
local DefaultJumpingPower
function Jump(character, JumpPower)
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then return end
humanoid.JumpPower = JumpPower
humanoid.Jump = true
wait(0.2)
humanoid.JumpPower = DefaultJumpingPower
end
local Player = game.Players.LocalPlayer
Player.CharacterAdded:Connect(function(character)
DefaultJumpingPower = character:WaitForChild("Humanoid").JumpPower
for i, v in pairs(JumpPadFolderChildren) do
if v:IsA("BasePart") then
v.Touched:Connect(function(part)
if part:IsDescendantOf(character) then
local JumpPowerValue = part:FindFirstChild("JumpPowerValue")
if not JumpPower then return end
Jump(character, JumpPowerValue.Value)
end
end)
end
end
end)
How are you concluding ping is not the problem? It obviously is. The only way to circumvent lag introduced by high ping is to run the code on the client, like I did.
This is an unsupported, unlikely, and ridiculous claim.
If you look at the video @SpacialEthanRB provided, you can see that the lag that occurs matches with the ping OP mentioned. Given that the jumping code is running on the server, it is logical to conclude that a high ping is indeed causing the delay. The fix for this can be found in my previous replies.