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

How do I fix this script that activates a door?

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

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.

3 comments

0

I think you made a mistake. Active is a BoolValue inside the script

0

Ah, sorry. Use Active instead of disabled then.

0

But it still didn't work

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