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

How come it won't take away the players control? [READ DESC.]

Asked by 8 years ago

Im trying to take away a players control so that it isn't able to move I check wiki but I have trouble with tables.Any videos or website,anything that can help me?.I tried to anchor the player Torso but its invalid or something.Any help? [[THIS IS NEW SCRIPT!!]].

local Code = script.Parent.Parent.Parent.Password.Code
local player = game.Players.LocalPlayer
local wrongs = 0
local Control = game.Players.LocalPlayer.PlayerScripts.ControlScript.Disabled

Control = true
function C()
if Code.Text == "2593316" then 
    wait(.1)
    Control = false
    wait(.1)
    player.PlayerGui.EntryGui.ENTER.TextButton.TextTransparency = 1
    wait(.1)
    Code.TextTransparency = 1
    wait(.1)
    Code.TextStrokeTransparency = 1
    wait(.1)
    player.PlayerGui.EntryGui.Black.Visible = false
    wait(.1)
else
    if wrongs == 0 then
    player.PlayerGui.EntryGui.Wrong1.Visible = true
wait(.5)
    player.PlayerGui.EntryGui.Wrong1.Visible = false
        wrongs = wrongs+1
     wait(.1)
    elseif wrongs == 1 then
    player.PlayerGui.EntryGui.Wrong1.Visible = false
    player.PlayerGui.EntryGui.Wrong2.Visible = true
wait(.5)
    player.PlayerGui.EntryGui.Wrong2.Visible = false
    wrongs = wrongs+1
     wait(.1)
    elseif wrongs == 2 then
    wrongs = wrongs+1
    player.PlayerGui.EntryGui.Wrong1.Visible = false
    player.PlayerGui.EntryGui.Wrong2.Visible = false
    player.PlayerGui.EntryGui.Wrong3.Visible = true
wait(.5)
    player.PlayerGui.EntryGui.Wrong3.Visible = false
wait(1)
    player.PlayerGui.EntryGui.Wrong1.Visible = true
wait(.1)
    player.PlayerGui.EntryGui.Wrong2.Visible = true
wait(.1)
    player.PlayerGui.EntryGui.Wrong3.Visible = true
wait(2)
    player:Kick()
        end
    end
end
script.Parent.MouseButton1Click:connect(C)


This is what the output said.Some of it is my plugins. 15:38:28.581 - Auto-Saving... Loaded gloo library. Type _G.gloo.Help() for help. 15:38:29.353 - ItemButton is not a valid member of Script 15:38:29.354 - Script 'Plugin_321426830.KinqStudioDailyAwardPlugin', Line 49 15:38:29.354 - Stack End Loading Cutscene Editor... 15:38:29.593 - Unable to load plugin icon. Image may have an invalid or unknown format. 15:38:29.597 - Unable to load plugin icon. Image may have an invalid or unknown format. 15:38:29.607 - Unable to load plugin icon. Image may have an invalid or unknown format. 15:38:29.621 - Unable to load plugin icon. Image may have an invalid or unknown format. 73681737 15:38:37.258 - ControlScript is not a valid member of PlayerScripts 15:38:37.258 - Script 'Players.Player.PlayerGui.EntryGui.ENTER.TextButton.LocalScript', Line 8 15:38:37.259 - Stack End

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

There are 2 good ways to take away control from Players. The first way, is to disable "ControlScript" inside game.Players.Player.PlayerScripts. When you want them to have control of their character again, enable the script and they will be able to control their character.

Another good way is to assign controls over the default ones. You could use the following script:

local ContextActionService = game:GetService("ContextActionService")
function onKeyPress(actionName, userInputState, inputObject)
    -- None of this stuff in this function is actually necessary. But it's good for reference!
    if actionName == "A" or actionName == "<" then
        if userInputState == Enum.UserInputState.Begin then
            print("A was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("A was let go")
        end
    elseif actionName == "W" or actionName == "^" then
        if userInputState == Enum.UserInputState.Begin then
            print("W was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("W was let go")
        end
    elseif actionName == "S" or actionName == "v" then
        if userInputState == Enum.UserInputState.Begin then
            print("S was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("S was let go")
        end
    elseif actionName == "D" or actionName == ">" then
        if userInputState == Enum.UserInputState.Begin then
            print("D was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("D was let go")
        end
    elseif actionName == "Shift" then
        if userInputState == Enum.UserInputState.Begin then
            print("Shift was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("Shift was let go")
        end
    elseif actionName == "Space" then
        if userInputState == Enum.UserInputState.Begin then
            print("Space was pressed")

        elseif userInputState == Enum.UserInputState.End then
            print("Space was let go")
        end
    end
end


ContextActionService:BindActionToInputTypes("A", onKeyPress, false, Enum.KeyCode.A)
ContextActionService:BindActionToInputTypes("W", onKeyPress, false, Enum.KeyCode.W)
ContextActionService:BindActionToInputTypes("S", onKeyPress, false, Enum.KeyCode.S)
ContextActionService:BindActionToInputTypes("D", onKeyPress, false, Enum.KeyCode.D)

ContextActionService:BindActionToInputTypes("<", onKeyPress, false, Enum.KeyCode.Left)
ContextActionService:BindActionToInputTypes("^", onKeyPress, false, Enum.KeyCode.Up)
ContextActionService:BindActionToInputTypes("v", onKeyPress, false, Enum.KeyCode.Down)
ContextActionService:BindActionToInputTypes(">", onKeyPress, false, Enum.KeyCode.Right)

ContextActionService:BindActionToInputTypes("Shift", onKeyPress, false, Enum.KeyCode.LeftShift)
ContextActionService:BindActionToInputTypes("Space", onKeyPress, false, Enum.KeyCode.Space)

When you want to unbind the above script, use the following:

ContextActionService:UnbindAction("A")
ContextActionService:UnbindAction("W")
ContextActionService:UnbindAction("S")
ContextActionService:UnbindAction("D")

ContextActionService:UnbindAction("<")
ContextActionService:UnbindAction("^")
ContextActionService:UnbindAction("v")
ContextActionService:UnbindAction(">")

ContextActionService:UnbindAction("Shift")
ContextActionService:UnbindAction("Space")
0
Ill test the control method I did it but added local player. jefftran60 5 — 8y
0
I tried both methods and they both didn't work. btw was the game.players.player.playerscripts.controlscript suppose to be like that? jefftran60 5 — 8y
0
Both methods are tested and work. You must have messed up in your script utilizing the methods. Validark 1580 — 8y
0
Ill try again. jefftran60 5 — 8y
0
I tried and it still doesn't work here Ill upload new my new script. jefftran60 5 — 8y
Ad

Answer this question