|
| 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 |
|
|
|
| 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 |
|
|
|
| 12 Jun 2013 09:42 AM |
How would you set the button and light to influence each other?
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 14 Jun 2013 06:38 PM |
| Actually, It doesn't look like it should matter |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2013 08:29 PM |
Ugh, not working, I can't seem to find anything wrong
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
| |
|
| |
|
| |
|
|
| 23 Jun 2013 06:21 PM |
| Whats the full script at this point |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 23 Jun 2013 06:30 PM |
| Range is a property of the Light... |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 06:31 PM |
| Herp derp range is a property XD 1 sec |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 24 Jun 2013 10:36 PM |
| Ugh, not working still and I have no idea why |
|
|
| Report Abuse |
|
|
| |
|
| |
|