generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can anyone tell my why part of this isn't working?

Previous Thread :: Next Thread 
KeysOfFate is not online. KeysOfFate
Joined: 04 Oct 2011
Total Posts: 7642
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
rockandrol120 is not online. rockandrol120
Joined: 03 Nov 2012
Total Posts: 52
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image