|
| 22 Aug 2017 12:20 AM |
Basically, the script turns on UserInputService once the player has entered a certain magnitude range.
But, the service doesn't turn off once the player exits said range.
How do I turn it off?
SCRIPT:
--VARIABLES
part = game.Workspace.Part
--DISTANCE DETECTOR LOOP
print("Detector loop begin...") repeat magnitude = (script.Parent.Head.Position - part.Position).magnitude --! Variable ! -- wait() if magnitude < 10 then part.CFrame = CFrame.new(part.Position, script.Parent.Head.Position) if game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled == false then wait(0.1) game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true game:GetService("UserInputService").InputBegan:connect(function(KeyPress) local K = KeyPress.KeyCode.Name if K == "E" then if part.Sound.Playing == false then print("Getting service") game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = false part.Sound.Playing = true wait(1) part.Sound.Playing = false game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true elseif part.Sound.Playing == true then wait(1) end else end end) end else print("beans") game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = false game:GetService("UserInputService").InputEnded:connect(function(KeyLift) end) end
until false
|
|
|
| Report Abuse |
|
|
| 22 Aug 2017 12:40 AM |
"local K = KeyPress.KeyCode.Name if K == "E" then"
Correct me if I'm wrong but should it be
if KeyPress == "e" then
|
|
|
| Report Abuse |
|