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

Why is my button not doing anything?

Asked by 8 years ago

I was just trying to make a simple button. But of course the button decides not to work because I probably made a mistake. I am scripting in a local script just putting this out there. Someone please help me.

Code:

--Made By: Troloolooolooll

local button = script.Parent

button.MouseEnter:connect(function()
    button.BackgroundColor3(141, 141, 141)
end)

button.MouseButton1Click:connect(function()
    local player = game.Players.LocalPlayer
    print(player.Name)
end)

button.MouseLeave:connect(function()
    button.BackgroundColor3(80, 80, 80)
end)

Edited: I put my gui in a folder. When I took it out of the folder it worked.

1 answer

Log in to vote
1
Answered by
pyro89 50
8 years ago

When changing the Color value of an object in RGB, you need to use Color3.new. But, you would also need to divide all three values, R, G, and B, by 255 or it will always be completely black or completely white. Inclusively make sure that the button is visible and accessible on the screen. My button was a TextButton residing in a ScreenGui.

local button = script.Parent

button.MouseEnter:connect(function()
    button.BackgroundColor3 = Color3.new(141/255, 141/255, 141/255)
end)

button.MouseButton1Click:connect(function()
    local player = game.Players.LocalPlayer
    print(player.Name)
end)

button.MouseLeave:connect(function()
    button.BackgroundColor3 = Color3.new(80/255, 80/255, 80/255)
end)
0
Thank you, but the fact is the functions aren't even being ran. So like nothing is happenning Troloolooolooll 9 — 8y
0
Showing entire script, also make sure that your button is visible on the screen, such as in a ScreenGui. pyro89 50 — 8y
0
I am showing my entire script. Also the button is visible and active. Troloolooolooll 9 — 8y
0
When running my script, both in Studio's Test Mode and playing in an actual server using it, the button worked fine. Without the Color3.new phrase inserted into the code, the script just gives the Button 3 numbers, with no idea how to use them. pyro89 50 — 8y
View all comments (3 more)
0
So do you know what the problem is or? Troloolooolooll 9 — 8y
0
I was sure the Color3 was the only problem. Did you at least insert the new code to see for yourself? pyro89 50 — 8y
0
Yes, I inserted the new code and didn't work, but the problem is that the functions aren't being ran. Troloolooolooll 9 — 8y
Ad

Answer this question