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

I want my tool to change colors on "KeyDown" explain how to do so?

Asked by 9 years ago

So, here's what I am thinking would be the best way of doing so:


Player = game.Players.LocalPlayer Mouse = game.Player:GetMouse() -- I don't know if you need this if you add animations or if you just need it for anything dealing with keydown events script.Parent.KeyDown:connect(function() if key == "r" then script.Parent.BrickColor = BrickColor.new("Really red") end end)

Alright, so that's basically what I think of how you'd change the color of a certain part. But here's what I need it to do:

  • I need it to basically Insert a Dynamic Lighting "Really red" light into the brick.

  • I need it to actually change colors, if you press each key, as in Red, Green, OR Blue.

1 answer

Log in to vote
0
Answered by 9 years ago
Player = game.Players.LocalPlayer
Mouse = game.Player:GetMouse() -- I don't know if you need this if you add animations or if you just need it for anything dealing with keydown events

script.Parent.KeyDown:connect(function()
local light = Instance.new("PointLight", script.Parent)
if key == "r" then
script.Parent.BrickColor = BrickColor.new("Really red") --Assuming "script.Parent" is a part
light.Color = Color3.new(255,0,0)
elseif key == "g" then
script.Parent.BrickColor = BrickColor.new("Lime green")
light.Color = Color3.new(0,255,0)
elseif key == "b" then
script.Parent.BrickColor = BrickColor.new("Really blue")
light.Color = Color3.new(0,0,255)
end
end)

Try this one. PointLights and Spot lights use Color3 instead of BrickColor.

0
Didn't work. TheReapersComing 0 — 9y
0
Well, what are you trying to do, and is it in a local script? I am pretty sure you can only "GetMouse" if it's in a GUI. EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question