I am using this script, copies strait from the wiki page 'http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character', and I am activating it with a remote event so that when a character touches a part, they are moved to a location and cannot cancel the script by moving, however no matter what, the player is still able to move.
Here is the script I am using to trigger the localscript on touch:
local event = Instance.new("RemoteEvent",game.ReplicatedStorage) event.Name = "removedControl" script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then event:FireClient(player,player) end end)
and here is the local script used to move the player and remove their control:
local event = game.ReplicatedStorage:WaitForChild("removedControl") local controllers = {} -- Create a table to store the controllers in local keysDown = {} -- Create a table to store all the key presses in local keyDown = false local mouse = game.Players.LocalPlayer:GetMouse() -- Luckily the KeyDown (and up) events will work on keys that are assigned to Roblox hot-keys while using PlayerMouse event.OnClientEvent:connect(function(p) function removeControl() repeat wait() until not keyDown -- Wait until no keys are being pressed (keyDown will be changed farther into the script) 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 mouse.KeyDown:connect(function(key) keysDown[key:upper()] = true -- Add the current key to a list of keys keyDown = true end) mouse.KeyUp:connect(function(key) keysDown[key:upper()] = false -- Tell the script that the key is no longer being pressed local hasKeyDown = false for key, isDown in pairs(keysDown) do -- Go through the list of keys that have been pressed if (isDown) then hasKeyDown = true -- Only set hasKeyDown to true if the key being checked is down end end keyDown = hasKeyDown -- If no keys were being pressed, this will be false. If a key was being pressed, this will be true end) removeControl() -- Disable their control over their character game.Players.LocalPlayer.Character.Humanoid:MoveTo(Vector3.new(-9.5, 2.5, -169)) -- Make the character walk somewhere end)
However I do not know why it still allows the player to walk! you can see I've even taken out the part of the script where it adds the players controls back to make sure that's not the case..
Help please!
(And Merry Christmas!!!)
I had the same problem i sloved it.
while script.Parent.Parent ~= nil do wait() local Player = script.Parent.Parent Player.PlayerScripts.ControlScript:remove() end
Put that in backpack.