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

how to cancel the moving from a character but make it still walk with MoveTo()?

okay so i have the code on how to move a character:

script.Parent.Touched:Connect(function(s)
    local position = Vector3.new(91, 0.5, 131.75)
    local humanoid = script.Parent:WaitForChild("Humanoid")
    humanoid:MoveTo(position)
end)

but i need to know how to make a character cancel its manual movement. (like have it controlled, but the player themselves cant manually move via arrow or wasd keys)

im planning to make a game like one of of those "tifany mayumi" gamer games.

pls help?

4 comments

0

Im looking at this script, and im pretty sure that having humanoid:MoveTo(position) would only teleport the player to the place that you want without having it walk there. To disabled the wasd keys and stuff, I think it could be a good idea to make the players walkspeed 0 at the times you it to be controlled.

0

you are thinking about model:MoveTo(). and the humanoid won't be able to move if its walkspeed is 0

0

but if i make the walkspeed 0, then the MoveTo() wouldnt work because the player cant move. ://

0

i cant see how to make the MoveTo() able to work without having the player be able to manually walk.

1 answer

You can use the context service for this:

local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"

ContextActionService:BindAction(
    FREEZE_ACTION,
    function() return Enum.ContextActionResult.Sink end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)

--to unfreeze

ContextActionService:UnbindAction(FREEZE_ACTION)

original: here

2 comments

0

is it supposed to be in all in one localscript?

0

try it out for yourself and achieve your desired results

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