Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making Character Move To Point but Still able to move left and right?

Asked by 9 years ago

Okay, so I'm making a game that you have to get from point A to Point B with obstacles inbetween.

I've tried using various ways to get the character to move forward, but I think the one I should use is the Humanoid's MovetoPoint Property.

I've successfully made a script that makes the character move to a specific point ahead in the stage, but the problem is, It wont let the character move left and right unless you tap the key multiple times quickly.

This is the script.

function a(b) 
if b.Parent:findFirstChild("Humanoid") ~= nil then 
local h = b.Parent:findFirstChild("Humanoid") 


if h ~= nil then 
while true do
h.WalkToPoint = Vector3.new(32.5, 8.3, -225.5)

wait(0.1)
end 
end


end 
end 
script.Parent.Touched:connect(a) 

1 answer

Log in to vote
0
Answered by 9 years ago

We can use the http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character

local controllers = {} --From the wiki

function removeControl()
    for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do
        controller.Parent = nil -- Take the controller out of ControllerService
        table.insert(controllers, controller)
    end
end

function resumeControl()
    for _, controller in pairs(controllers) do
        controller.Parent = game:GetService("ControllerService") ControllerService
    end
    controllers = {} -- Clear the table
end

removeControl() -- Disable their control over their character
game.Players.LocalPlayer.Character.Humanoid.WalkToPoint = Vector3.new(32.5, 8.3, -225.5)
wait(5) --How long it takes for the character to move there.
resumeControl() -- Give them control over their character again

Hope this gives you an idea!

Ad

Answer this question