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

How do I change the color on a MouseButton1Click event?(edited from previous)

Asked by 9 years ago

When I equip the tool, the gui pops up and there are text buttons. When I click the text buttons, I want to change the color to red if its green and green if its red, but when I click it the button says " r cannot be assigned to" and that's it.

script.Parent.TextButtona.MouseButton1Click:connect(function()
    if debouncea == false then
    debouncea = true
    a.BackgroundColor3.r = (170)
    a.BackgroundColor3.g = (16)
    a.BackgroundColor3.b = (19)
    elseif debouncea == true then
    debouncea = false
    c.BackgroundColor3.r = (25)
    c.BackgroundColor3.g = (170)
    c.BackgroundColor3.b = (15)
    end
end)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

You need to access the Player's GUI, not the game's.

Local Script inside of the tool:

script.Parent.Equipped:connect(function()
    game.Players.LocalPlayer.PlayerGui["Security Tablet"].Frame.Visible = true
end)

script.Parent.Unequipped:connect(function()
    game.Players.LocalPlayer.PlayerGui["Security Tablet"].Frame.Visible = false
end)
Ad

Answer this question