Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Latency between Client and Server, Character appearing in different positions? [PROBABLY SOLVED]

I'm trying to make a round role based game where a person gets anchored when someone else sees them. The problem is, that person is fast so when they get anchored.. they are a few studs away from where they actually are on the server.

Usually this would visually be ok, it doesn't really matter but the problem is when once the person looking at them looks away, the server realizes the client is in a different position than serverside so it just immediately gets rid of the real position in the server and replaces it with the fake one where the anchored player is, which makes a teleport which is not a good bug to have.

I have tried many solutions on fixing this such as, moving the player position smaller than a stud which fixed the position but it was a temporary fix because it later on broke code that was required. Sending positions using remote events but that was just really buggy and unreliable to work with.

Here's my code for anchoring the player, it's VERY small. All it does is anchor the fast player which is the problem.

local function StopWA()
	for i, parts in pairs(script.Parent:GetChildren()) do
		if parts:IsA("MeshPart") and parts.Name ~= "Hitbox" or parts:IsA("Part") and parts.Name ~= "Hitbox" then
			parts.Anchored = true
		end
	end
end

3 comments

0

I think I understand what you want. The best possible way to do this would be to capture the position locally, and send it to the server via a RemoteEvent. The server will handle the process of teleporting it to where it originally was.

0

Nevermind, that isn't what you were asking for.

0

I forgot to mention this BUT changing the position serverside at ALL will break my code. It must be locally or just preventing this issue serverside somehow.

1 answer

Alright, I think I have found a solution. For people that have the same problem as me.. this is what I did.

I made a Remote Event and a Local Script, I have done something similar to this to try to fix this problem but it didn't work. What I'll be trying differently here is just by sending the CFrame for the HumanoidRootPart from the server to local.

This seems to work so far from my testing, only VISUAL bug that I get all the time anyway when I even try to fix this is that the player being frozen visually gets TPED on their screen which is expected.

Server

local function StopWA()
	for i, parts in pairs(script.Parent:GetChildren()) do
		if parts:IsA("MeshPart") and parts.Name ~= "Hitbox" or parts:IsA("Part") and parts.Name ~= "Hitbox" then
			parts.Anchored = true
		end
	end
	game:GetService("ReplicatedStorage").WA:FireClient(plrW, "Fix", script.Parent.HumanoidRootPart.CFrame)
end

Local

local plr = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum. CoreGuiType. Health, false)

game.ReplicatedStorage.WA.OnClientEvent:Connect(function(Check, P)
	
	
	if Check == "Fix" then
		plr.Character.HumanoidRootPart.CFrame = P
	else
		for i, S in pairs(plr.Character.HumanoidRootPart:GetChildren()) do
			if S:IsA("Sound") then
				S:Destroy()
			end
		end
		
		for i, S in pairs(plr.Character:GetChildren()) do
			if S:IsA("Part") or S:IsA("MeshPart") then
				S.Transparency = 1
			end
		end
	end
		
end)

If something does break I'll make sure to update this post!

This discussion is preserved as it was. New answers, comments, and votes are closed.