Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

2 comments

0

Didn't work.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.