Freeze effect not being Acurate

Hello!

Code

function Globals.IceFreeze(hit, amount ,ice)
	ice.CanCollide = false
	ice.Anchored = true
	
	local Weld = Instance.new("WeldConstraint")
	Weld.Parent = ice
	Weld.Part0 = hit.Parent:FindFirstChild("HumanoidRootPart")
	Weld.Part1 = ice


	if hit.Parent.Humanoid.Health < 0 or hit.Parent:FindFirstCHild("Humanoid") ~= nil then
		ice:Destroy()
	else
		hit.Parent.Humanoid.PlatformStand = true
		hit.Parent.HumanoidRootPart.Anchored = true
		wait(0.1)
		ice.Parent = workspace
		ice.CFrame = hit.Parent.HumanoidRootPart.CFrame
		hit.Parent.Geppo.Value = "Not"
		hit.Parent.Stun.Value = "Yes"
		wait(amount)
		ice:Destroy()
		if hit.Parent.Humanoid.Health > 0 or hit.Parent:FindFirstCHild("Humanoid") ~= nil then
			hit.Parent.Stun.Value = "No"
			hit.Parent.Geppo.Value = "Can"
			hit.Parent.Humanoid.PlatformStand = false
			hit.Parent.HumanoidRootPart.Anchored = false
		end
	end
	
end

I’m making a freeze function and I’m having trouble with making the effect always be in the center of the player ( or not making the effect be where the character used to be). To be more clear I want the position of the ice effect to always be…

hit.Parent.HumanoidRootPart.CFrame

The problem with this code is that sometimes there’s a little delay and the freeze effect (Variable ice) position is not always…

hit.Parent.HumanoidRootPart.CFrame

**The question I have is that how can I make it so that the position of this effect always be…

hit.Parent.HumanoidRootPart.CFrame

If this code is being ran from the server then this is a natural effect of the server not being able to perceive physics as fast as the client. If the player is moving and the ice effect function is called then the server might see an older position than the client does.

If it’s not important for the ice block to exist on the server (you aren’t relying on the block’s collision space, transparency or its existence at all) you can create the block on each client so that it’ll use a more accurate position. If you absolutely need to make it from the server you’ll need to delay its creation so that the server can catch up with the character’s current position.

1 Like

Yep @colbert2677 has the explanation, the solution is well it’s been done before here:

This way is great but it only handles players. In my game you can attack NPCS also so I’m wondering how I would be able to do this with NPCS as well as players

You can just do fire all clients and update it locally to match the server.