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

How do I fix this script that activates a door?

Asked by 4 years ago

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:

script.Parent.MouseHoverEnter:Connect(function(plr)
    game.Players[plr.Name].PlayerGui.InteractionMenu.Enabled = true
    game.Players[plr.Name].PlayerGui.InteractionMenu.ItemName.Text = "Control Panel"
    game.Players[plr.Name].PlayerGui.InteractionMenu.HoldF.Text = "Hit [F] to open door"
    script.Active.Value = true
end)

script.Parent.MouseHoverLeave:Connect(function(plr)
    game.Players[plr.Name].PlayerGui.InteractionMenu.Enabled = false
    script.Active.Value = false
end)

game:GetService("UserInputService").InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.F and script.Active == true and script.Parent.Parent.Parent.Panel.SurfaceGui.Control3.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then
        script.Parent.Parent.Parent.Panel.SurfaceGui.Control3.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    end
end)

Why won't it work? Bit of help please. Thx

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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:

script.Parent.MouseHoverEnter:Connect(function(plr)
    game.Players[plr.Name].PlayerGui.InteractionMenu.Enabled = true
    game.Players[plr.Name].PlayerGui.InteractionMenu.ItemName.Text = "Control Panel"
    game.Players[plr.Name].PlayerGui.InteractionMenu.HoldF.Text = "Hit [F] to open door"
    script.Active.Value = true
end)

script.Parent.MouseHoverLeave:Connect(function(plr)
    game.Players[plr.Name].PlayerGui.InteractionMenu.Enabled = false
    script.Active.Value = false
end)

game:GetService("UserInputService").InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.F and script.Active == true and script.Parent.Parent.Parent.Panel.SurfaceGui.Control3.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then
        script.Parent.Parent.Parent.Panel.SurfaceGui.Control3.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
    end
end)

Please accept and upvote this answer if it helped.

0
I think you made a mistake. Active is a BoolValue inside the script JB_SuperGamer 165 — 4y
0
Ah, sorry. Use Active instead of disabled then. youtubemasterWOW 2741 — 4y
0
But it still didn't work JB_SuperGamer 165 — 4y
Ad

Answer this question