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

How do I make an automatic control system?

Asked by
Sam4550 42
7 years ago

I know this is a bit of a long shot but I'm making a script that forces characters to walk on a path through different bookmark points. When this block gets hit by a player, it moves that player to the next part. How would I get it so that it stops the player from being able to control their character? Thanks!

function touched(part)
    if part.Name == "Head" then
        local player = game.Players:GetPlayerFromCharacter(part.Parent)
        player.Character.Humanoid:MoveTo(script.Parent.Parent.Part1.Position)
    end
end

script.Parent.Touched:connect(touched)

1 answer

Log in to vote
0
Answered by 7 years ago

Each player has a script named ControlScript which allows each player to use a input device such as KeyBoard, GamePad, etc to move there character. Note this is just the default one and can be overwritten if the developer of the game does so. So as long as you don't write a new one this will work. ControlScript is a child of PlayerScripts which is a child of player. So we just simply have to disable the script to not let them move. You will have to enable it again to allow them to move their character.

function touched(part)
    if part.Name == "Head" then
        local player = game.Players:GetPlayerFromCharacter(part.Parent)
    player.PlayerScripts.ControlScript.Disabled = true
        player.Character.Humanoid:MoveTo(script.Parent.Parent.Part1.Position)
    end
end

script.Parent.Touched:connect(touched)
0
Sorry but it won't let me go into PlayerScripts, something to do with it being a Local Script Sam4550 42 — 7y
Ad

Answer this question