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 » Scripting Helpers
Home Search
 

Re: Button light

Previous Thread :: Next Thread 
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
11 Jun 2013 07:28 PM
Heyo, I was wondering how to make this


--This is a LocalScript
local Studs = 5 -- How many studs maximum to enable/disabled light.
local Light = Game.Workspace.Spotlight1.Light.Button -- Change this to what you need.

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Light.Parent.Position - Player.Character.Torso.Position).magnitude < Studs then
Light.Range = Light.Range == 5 and 0 or 5
end
end)



reference a button in the model that you would have to be close to to turn on the light.
The current config of this script is to turn it on by the block that contains the light
It would also be interesting to change the color of the button from red ( off) to green (on) when e is pressed
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
11 Jun 2013 07:35 PM
To change the color you'd just do:

--This is a LocalScript
local Studs = 5 -- How many studs maximum to enable/disabled light.
local Button = Game.Workspace.Button -- Change this to what you need.

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Button.Position - Player.Character.Torso.Position).magnitude < Studs then
Button.BrickColor = Button.BrickColor == BrickColor.new("Really red") and BrickColor.new("Lime green") or BrickColor.new("Really red")
end
end)

P.S. I made that script.
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
12 Jun 2013 09:42 AM
How would you set the button and light to influence each other?
Report Abuse
Lukekneenew is not online. Lukekneenew
Joined: 20 Oct 2009
Total Posts: 746
12 Jun 2013 10:51 AM
local Studs = 5 -- How many studs maximum to enable/disabled light.
local Light = Game.Workspace.Spotlight1.Light.Button -- Change this to what you need.

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Light.Parent.Position - Player.Character.Torso.Position).magnitude < Studs then
Light.Enabled = not Light.Enabled
end
end)

Dis work?
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
12 Jun 2013 11:08 AM
The problem is that the light is not in the button!

That means I don't know how to reference the light and the button in the script.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jun 2013 01:59 PM
Oh, okay. Try this:

--This is a LocalScript
local Studs = 5 -- How many studs maximum to enable/disabled light.
local Button = Game.Workspace.House.Button -- Change this to what you need.
local Light = Game.Workspace.Spotlight1.Light -- Change this to what you need.

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Button.Position - Player.Character.Torso.Position).magnitude < Studs then
Light.Range = Light.Range == 5 and 0 or 5
end
end)
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
14 Jun 2013 06:21 PM
Umm... sorry to have to ask this, but should I put this in the button or light?
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
14 Jun 2013 06:38 PM
Actually, It doesn't look like it should matter
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
14 Jun 2013 08:29 PM
Ugh, not working, I can't seem to find anything wrong
Report Abuse
HillBilly9843 is not online. HillBilly9843
Joined: 05 Jan 2009
Total Posts: 7870
14 Jun 2013 08:42 PM
Try using KeyUp instead, I had a broken script using keys and all I had to do was make it Up instead.
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
22 Jun 2013 02:59 PM
Ill try that
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
22 Jun 2013 03:05 PM
Change
Game
to
game

A dur
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
23 Jun 2013 05:16 PM
no work
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
23 Jun 2013 05:32 PM
Gahhhhhhhhhh
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
23 Jun 2013 06:19 PM
bump
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
23 Jun 2013 06:21 PM
Whats the full script at this point
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
23 Jun 2013 06:22 PM
Where is the script located. LocalScripts will only run as a descendant of a player or character.

Also Game == game
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
23 Jun 2013 06:24 PM
I changed the Game to game, and thought that I had properly referenced the parts



--This is a LocalScript
local Studs = 5 -- How many studs maximum to enable/disabled light.
local Button = game.Workspace.Spotlight1.Button -- Change this to what you need.
local Light = game.Workspace.Spotlight1.Light.Spotlight -- Change this to what you need.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Button.Position - Player.Character.Torso.Position).magnitude < Studs then
Light.Range = Light.Range == 5 and 0 or 5
end
end)
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
23 Jun 2013 06:29 PM
Range isn't defined, unless it's some sort of already defined thing that I haven't seen. Other than that I can't help you
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
23 Jun 2013 06:30 PM
Range is a property of the Light...
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
23 Jun 2013 06:31 PM
Herp derp range is a property XD 1 sec
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
23 Jun 2013 06:35 PM
--I'm not really sure... sometimes and else statement helps. Try this

local Studs = 5
local Button = game.Workspace.Spotlight1.Button
local Light = game.Workspace.Spotlight1.Light.Spotlight

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key:lower() == "e" and (Button.Position - Player.Character.Torso.Position).magnitude < Studs then
Light.Range = Light.Range == 5 and 0 or 5
else Light.Range = Light.Range
end
end)
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 Jun 2013 10:36 PM
Ugh, not working still and I have no idea why
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
25 Jun 2013 11:45 AM
bump
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
26 Jun 2013 09:08 AM
Any ideas?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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