|
| 24 Jul 2015 11:50 PM |
| Is there a way to disable the character movements (arrows or WASD keys)? I just want to disable them to make the player walk to a point without cancelling it. I tried to use the WalkToPoint and the player just has to press "S" to cancel it. I don't want this to happen. Thank you in advance! |
|
|
| Report Abuse |
|
|
|
| 24 Jul 2015 11:58 PM |
If you want to disable them for the entire game, insert a LocalScript in to StarterPlayerScripts and name it "ControlScript". You don't have to do anything more, except maybe delete the print statement inside.
If you only want it to be temporary, try: http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 12:04 AM |
I went exactly on this link before. The problem in this script is that we CAN free moving even if the character is obligated to move to a point. I want that the player, when he presses WASD or arrow keys, to not be able to move. For example. In a script, you disable the movements and obligate the player to walk to Vector3.new(50, 0, 60) for 5 seconds. While those 5 seconds, he cannot turn left, right, forward or backward; just to the given point.
Sorry if I'm not clear, I don't speak much English. :/ |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 25 Jul 2015 12:20 AM |
just disable the control script for how long you want it to be disabled, and re-enable it when you want to. if you're game uses FE, this should work (didnt test):
-- server script game.Players.PlayerAdded:connect(function(plr) event = Instance.new("RemoteEvent", plr) event.Name = plr.Name.."'s event" wait(3) event:FireClient(plr, 5) end)
--[[ whenever you want to disable controls, call event:FireClient(your specified player, amount of time controls are disabled). for testing purposes, i fire it when he first joins the game after 3 seconds. the second argument you choose for this remote event is the amount of time the script is disabled]]
-- local script local plr = game.Players.LocalPlayer local event = plr:WaitForChild(plr.Name.."'s event")
event.OnClientEvent:connect(function(time) local controlSkropt = script.Parent:FindFirstChild("ControlScript") if controlSkropt then controlSkropt.Disabled = true wait(time) controlSkropt.Disabled = false else print("control script not found") end end)
try that? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 25 Jul 2015 12:22 AM |
*for testing purposes, i call it when he first joins the game after 3 seconds.
blah
and also, make sure you put the local script in StarterPlayerScripts. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 12:26 AM |
| So there's a thing called PlayerScripts inside the Player? Never knew that. But a big thank you! It works! :D |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 12:31 AM |
@nicemike40 That service doesn't work anymore. |
|
|
| Report Abuse |
|
|
XYuy
|
  |
| Joined: 24 Dec 2010 |
| Total Posts: 5628 |
|
|
| 25 Jul 2015 12:33 AM |
for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do controller.Parent = nil end |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 12:39 AM |
Nevermind, it's not working. :/ No outputs found. Even the prints are not working .-. |
|
|
| Report Abuse |
|
|
| |
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 25 Jul 2015 02:37 AM |
if my script didn't work, and if you aren't using FE, just do this:
disable the ControlScript inside of the player's playerscripts make the character walk to where ever you want using humanoid:MoveTo(vector3) wait until he reaches his destination with humanoid.MoveToFinished event re-enable his control script, then do whatever |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2015 11:24 AM |
So, yeah, my bad, wasn't aware that service wouldn't work anymore.
I whipped up this function, it probably works:
local function ForcePlayerTo(player, position) local character = player.Character if character then local humanoid = character:FindFirstChild("Humanoid") if humanoid then local control = player.PlayerScripts:FindFirstChild("ControlScript") local connection; connection = humanoid.MoveToFinished:connect(function() control.Disabled = false connection:disconnect() end) humanoid:MoveTo(position) control.Disabled = true end end end
--[[ example usage in LocalScript ]]
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
mouse.Button1Down:connect(function() if not mouse.Target then return end ForcePlayerTo(player, mouse.Hit.p) end)
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|