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
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!