Why does the player still move a bit after being anchored?

script:

local event = game.ReplicatedStorage.Events.FireEvent
local tweenservice = game:GetService("TweenService")
event.OnServerEvent:Connect(function(plr,Mouse,look)
	plr.Character.HumanoidRootPart.Anchored = true
	local part = game.ReplicatedStorage.Ball:Clone()
	part.Parent = workspace
	part.CFrame = plr.Character.Torso.CFrame*CFrame.new(0,-5,-3) 

	local tweenInfo = TweenInfo.new(0.3) -- Change the duration as needed
	local tween = tweenservice:Create(part, tweenInfo, {CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position + look * 6)})
	
	
	local downForce = - part:GetMass() * workspace.Gravity + 300
	local force = -downForce
	part.Value.Value = plr.Name
	local bodyForce = Instance.new("BodyForce")
	bodyForce.Force = Vector3.new(0,force,0)
	bodyForce.Parent = part
	tween:Play()
	wait(0.4)
	plr.Character.HumanoidRootPart.Anchored = false
	part.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse).LookVector * 150
end)

as you can see, the player’s torso should be anchored the moment the event fires, but there was still some room apparently for the player to go forward, any idea how i can fix it?

3 Likes

There’s latency between when the server event is fired and when it is received

4 Likes

this is way too long for a client server event, any idea how i could fix it? maybe anchor the player clientside?

1 Like


oops i meant to send a video

1 Like

Hmm, yeah that is definitely not a latency issue. It seems to me like something is un-anchoring the rootpart. I would recommend trying to set the humanoid walkspeed to 0 instead of anchoring the rootpart.

2 Likes

nope, still the same problem. this is the client script if it helps:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local event = game.ReplicatedStorage.Events.FireEvent

local hum = script.Parent:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(game.ReplicatedStorage.Animation)
db = false
mouse.Button1Down:Connect(function()
	if db == false then
		db = true
		event:FireServer(mouse.Hit.Position,mouse.Hit.LookVector)
		anim:Play()
		wait(1)
		db =false
	end
	
end)
1 Like

Can you confirm via the explorer that the Humanoid walkspeed is being set to 0?
Or run some debug prints

Try removing the section where the rootpart gets re-anchored and see if it still occurs

1 Like


maybe momentum?

1 Like

Try replacing

wait(0.4)
plr.Character.HumanoidRootPart.Anchored = false
part.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse).LookVector * 150

with

local onCompleted = tween.Completed:Connect(function()
plr.Character.HumanoidRootPart.Anchored = false
part.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse).LookVector * 150
onCompleted:Disconnect()
end)

1 Like

1 Like

i did this if thats what you meant:

local event = game.ReplicatedStorage.Events.FireEvent
local tweenservice = game:GetService("TweenService")
event.OnServerEvent:Connect(function(plr,Mouse,look)
	plr.Character.HumanoidRootPart.Anchored = true
	local part = game.ReplicatedStorage.Ball:Clone()
	part.Parent = workspace
	part.CFrame = plr.Character.Torso.CFrame*CFrame.new(0,-5,-3) 

	local tweenInfo = TweenInfo.new(0.3) -- Change the duration as needed
	local tween = tweenservice:Create(part, tweenInfo, {CFrame = CFrame.new(plr.Character.Head.Position + look * 6)})
	tween:Play()
	
	local downForce = - part:GetMass() * workspace.Gravity + 300
	local force = -downForce
	part.Value.Value = plr.Name
	local bodyForce = Instance.new("BodyForce")
	bodyForce.Force = Vector3.new(0,force,0)
	bodyForce.Parent = part


	tween.Completed:Connect(function()
		plr.Character.HumanoidRootPart.Anchored = false
		part.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse).LookVector * 150

	end)
end)
1 Like

(didn’t work btw if you are wondering)

1 Like

this is always going to happen. it takes time to fire an event from the client to the server meaning you are going to move

only way to fix it is to anchor and unachor the root part on the client and let the server deal with the ball

Stop walking anim then anchor the feet or a foot. Can’t move with your feet stuck to the floor.