Yes... I've asked a few questions today, but this one is the one that's bugging me most. When F is pressed, this light will turn green on a Panel. But it didn't work. Here's the code:
01 | script.Parent.MouseHoverEnter:Connect( function (plr) |
02 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.Enabled = true |
03 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.ItemName.Text = "Control Panel" |
04 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.HoldF.Text = "Hit [F] to open door" |
05 | script.Active.Value = true |
06 | end ) |
07 |
08 | script.Parent.MouseHoverLeave:Connect( function (plr) |
09 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.Enabled = false |
10 | script.Active.Value = false |
11 | end ) |
12 |
13 | game:GetService( "UserInputService" ).InputBegan:Connect( function (key) |
14 | if key.KeyCode = = Enum.KeyCode.F and script.Active = = true and script.Parent.Parent.Parent.Panel.SurfaceGui.Control 3. BackgroundColor 3 = = Color 3. fromRGB( 255 , 0 , 0 ) then |
15 | script.Parent.Parent.Parent.Panel.SurfaceGui.Control 3. BackgroundColor 3 = Color 3. fromRGB( 255 , 0 , 0 ) |
16 | end |
17 | end ) |
Why won't it work? Bit of help please. Thx
Problem: Gui won't turn green on "F".
Solution: Use Color3.fromRGB(0, 255, 0)
.
Explanation: You made the script set the BackgroundColor3
to red (255, 0, 0) instead of green (0, 255, 0).
Fixed script:
01 | script.Parent.MouseHoverEnter:Connect( function (plr) |
02 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.Enabled = true |
03 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.ItemName.Text = "Control Panel" |
04 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.HoldF.Text = "Hit [F] to open door" |
05 | script.Active.Value = true |
06 | end ) |
07 |
08 | script.Parent.MouseHoverLeave:Connect( function (plr) |
09 | game.Players [ plr.Name ] .PlayerGui.InteractionMenu.Enabled = false |
10 | script.Active.Value = false |
11 | end ) |
12 |
13 | game:GetService( "UserInputService" ).InputBegan:Connect( function (key) |
14 | if key.KeyCode = = Enum.KeyCode.F and script.Active = = true and script.Parent.Parent.Parent.Panel.SurfaceGui.Control 3. BackgroundColor 3 = = Color 3. fromRGB( 255 , 0 , 0 ) then |
15 | script.Parent.Parent.Parent.Panel.SurfaceGui.Control 3. BackgroundColor 3 = Color 3. fromRGB( 0 , 255 , 0 ) |
16 | end |
17 | end ) |
Please accept and upvote this answer if it helped.