Roblox Player High Ping but not in Studio, is it because of a script or something else?

  1. What do you want to achieve? Optimize the current features of my game before working on the new one

  2. What is the issue? I always kept getting high ping in Roblox Player but not inside Studio, Is It because of a script or something?

  3. What solutions have you tried so far? I tried searching up which things affect ping on Roblox, but I still don’t know how to fix it

EDIT: tried disabling the script, but the ping is still high… the script is not the impostor

Here is the performance of my game inside Roblox Studio

And here is the performance inside Roblox Player

And here is the script which I guess cause it

local rs = game.ReplicatedStorage
local remotes = rs.GameStorage.Remotes

game.Players.PlayerAdded:Connect(function(player)
	local sprinting = false
	local freefalling = false
	local canregen = true
	local activated = 0
	local cansprint = true
	
	local datafolder = player:WaitForChild("PlayerDataFolder")
	local playerstatus = datafolder:WaitForChild("PlayerStatus")
	local experiencestatus = datafolder:WaitForChild("ExperienceStatus")


	local maxStamina = playerstatus.MaxStamina
	local stamina = playerstatus.Stamina
	local speed = playerstatus.Speed
	local level = experiencestatus.Level
	
	player.CharacterAdded:Connect(function(char)

		local hum = char.Humanoid

		if maxStamina.Value == 0 then
			maxStamina.Value = 50
		end

		if stamina.Value == 0 then
			stamina.Value = maxStamina.Value
		end
		
		hum.StateChanged:Connect(function(old, new)	
			if new == Enum.HumanoidStateType.Running then
				cansprint = true
			elseif new == Enum.HumanoidStateType.Freefall then
				cansprint = false
			end	
		end)
	end)
	
	remotes.StaminaChange.OnServerEvent:Connect(function(player, state)
		
		local character = player.Character or player.CharacterAdded:Wait()
		local hum = character:WaitForChild("Humanoid")

		if state == "SprintStart" and hum.moveDirection.Magnitude > 0 and cansprint == true then
			hum.WalkSpeed = speed.Value * 1.52	
			stamina.Value = stamina.Value - 1
			sprinting = true
		elseif state == "SprintEnd" then
			hum.WalkSpeed = speed.Value
			sprinting = false
		end

		if state == "WalkEnabled" then
			hum.WalkSpeed = speed.Value / 2.4
		elseif state == "WalkDisabled" then
			hum.WalkSpeed = speed.Value
		end
	end)
	
	while stamina.Value < maxStamina.Value do
		wait(.001)
		
		if canregen == true and sprinting == false then
			wait(1)
			if sprinting == false then
				wait(1)
				if stamina.Value <= maxStamina.Value and sprinting == false and canregen == true then
					while sprinting == false and canregen == true do
						wait(.0001)
						if stamina.Value > maxStamina.Value then
							stamina.Value = maxStamina.Value
						elseif stamina.Value < maxStamina.Value then
							stamina.Value = stamina.Value + 1 
							wait(0.0001)
						end
					end
					if stamina.Value == maxStamina.Value then
						canregen = false
					end
				end
			end
		end

		if stamina.Value <= maxStamina.Value then
			
			local character = player.Character or player.CharacterAdded:Wait()
			local hum = character:WaitForChild("Humanoid")

			if sprinting == true and hum.MoveDirection.Magnitude == 0 then
				activated = 2
				sprinting = false
				hum.WalkSpeed = speed.Value
			end

			if sprinting == false and stamina.Value < maxStamina.Value then
				activated = 0
			end

			if sprinting == true and hum.MoveDirection.Magnitude > 0 and cansprint == true then
				canregen = false
				if stamina.Value >= 1 then
					stamina.Value = stamina.Value - 1
					wait(0.0001)
				elseif stamina.Value < 1 then
					activated = 1
					hum.WalkSpeed = speed.Value
					sprinting = false
				end
			end

			if stamina.Value < 1 and activated == 1 and canregen == false and sprinting == false then
				canregen = true
			elseif sprinting == true and hum.MoveDirection.Magnitude == 0 and activated == 2 and canregen == false then
				canregen = true
			elseif sprinting == false and stamina.Value < maxStamina.Value and activated == 0 and canregen == false then
				canregen = true
			end
		end
	end
end)


and any advice will help, thanks!

You will just have a bad internet connection. I’m pretty sure the server in roblox studio is a local server running off your own computer so that’s why its so much faster vs a roblox server which is an actual server somewhere much further away. Someone correct me if I’m wrong but I believe that is the case as I have experienced the same issues before.

2 Likes

I think its thats true, I have experienced a average of 300 ping (being in Australia, and probably has US servers) on the player, while studio giving me about 70.

2 Likes