I have this script that forces the player to walk forward until it hits a brick, which is SUPPOSED to make the character regain control.
The problem is, I don't know what to put in the vector3 part to make the character walk with controls. Doing 0,0,0 does't work, it just makes the character go to those chords. I have also tried nil and nil,nil,nil but those do the same.
This is the script in the brick that's supposed to change it back to normal
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.4, 8.4, 32.8) wait() end end end end script.Parent.Touched:connect(a)
http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character So we can get rid of the ability to walk and give it back with this script.
local controllers = {} -- Create a table to store the controllers in function removeControl() for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do controller.Parent = nil -- Take the controller out of ControllerService table.insert(controllers, controller) -- Save it for later end end function resumeControl() for _, controller in pairs(controllers) do controller.Parent = game:GetService("ControllerService") -- Put the controller back into ControllerService end controllers = {} -- Clear the table end removeControl() -- Disable their control over their character game.Players.LocalPlayer.Character.Humanoid:MoveTo(Vector3.new(0, 0, 0)) -- Make the character walk somewhere wait(5) resumeControl() -- Give them control over their character again
Now we add this with your script:
local controllers = {} function removeControl() for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do controller.Parent = nil -- Take the controller out of ControllerService table.insert(controllers, controller) -- Save it for later end end function resumeControl() for _, controller in pairs(controllers) do controller.Parent = game:GetService("ControllerService") -- Put the controller back into ControllerService end controllers = {} -- Clear the table end function a(b) if b.Parent:findFirstChild("Humanoid") ~= nil then local h = b.Parent:findFirstChild("Humanoid") if h ~= nil then removeControl() h.WalkToPoint = Vector3.new(32.4, 8.4, 32.8) end wait(5) --After sometime resumeControl() end end script.Parent.Touched:connect(a)
It's late so I cant really explain, I hope it helps!