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

How do i Disable Keyboard Input In My Script?? [closed]

Asked by
sammiya1 134
8 years ago
Edited 8 years ago
01local Hit = game.Workspace.Model.Hit
02local L1 = game.Workspace.Model.L1
03local End = game.Workspace.Model.End 
04 
05function onTouched(hit)
06if hit.Parent:FindFirstChild("Humanoid") then --check if the part is part of the humanoid's body
07        local character = hit.Parent --character (player model on the workspace)
08        local humanoid = character:WaitForChild("Humanoid") --humanoid found inside the player's character
09        humanoid:MoveTo(L1.Position)
10 
11end
12end
13 
14script.Parent.Touched:connect(onTouched)

So all i want to do is that during this script running the player can not imput any movement controls from the keyboard whilst the script is running. Basically disable it till its done.

0
so humanoid.PlatformStand = true sammiya1 134 — 8y

Locked by youtubemasterWOW and zblox164

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
itsJooJoo 195
8 years ago
Edited 8 years ago

Problem

You want to disable the character's movement abilities until it's done

Solution

A humanoid has the option in the properties bar to change movement and such. Add this to the script:

1humanoid.Walkspeed = 0
2humanoid.JumpPower = 0
3wait(1)

and this after:

1wait(1)
2humanoid.Walkspeed = 16
3humanoid.JumpPower = 50

This'll wait for one second before TPing the player and it'll freeze the player for 2 seconds.

Final Script

01local Hit = game.Workspace.Model.Hit
02local L1 = game.Workspace.Model.L1
03local End = game.Workspace.Model.End 
04 
05function onTouched(hit)
06    if hit.Parent:FindFirstChild("Humanoid") then
07            local character = hit.Parent
08        local humanoid = character:WaitForChild("Humanoid")
09        humanoid.Walkspeed = 0
10        humanoid.JumpPower = 0
11        wait(1)
12            humanoid:MoveTo(L1.Position)
13        wait(1)
14        humanoid.Walkspeed = 16
15        humanoid.JumpPower = 50
16    end
17end
18 
19script.Parent.Touched:connect(onTouched)

Suggestions

I recommend using CFrames rather than humanoid:MoveTo, and also changing game.Workspace to simply "workspace". With following these suggestions, THIS would be the final script:

01local Hit = workspace.Model.Hit
02local L1 = workspace.Model.L1
03local End = workspace.Model.End 
04 
05function onTouched(hit)
06    if hit.Parent:FindFirstChild("Humanoid") then
07            local character = hit.Parent
08        local torso = character.Torso
09        local humanoid = character:WaitForChild("Humanoid")
10        humanoid.Walkspeed = 0
11        humanoid.JumpPower = 0
12        wait(1)
13            torso.CFrame = CFrame.new(L1.Position)
14        wait(1)
15        humanoid.Walkspeed = 16
16        humanoid.JumpPower = 50
17    end
18end
19 
20script.Parent.Touched:connect(onTouched)

If this helped you, be sure to accept my answer! It helps both of us!

Ad