What do you want to achieve? Keep it simple and clear!
When a player hovers over a TextButton a frame’s background color will change
What is the issue? Include screenshots / videos if possible!
When I hover over the text button it doesn’t change the background color of the frame
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did not find much that could help me, I got no errors in the output I also tried using “BrickColor.new()” but I couldn’t find the right colors.
The TextButton is placed over the ImageLabel and InfoButton
heres my script:
local back = game.StarterGui.ApplyGui.BackFrame.SideFrame.Info
script.Parent.MouseEnter:Connect(function()
back.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
end)
script.Parent.MouseLeave:Connect(function()
back.BackgroundColor = Color3.fromRGB(40, 40, 40)
end)
The problem here is that you’re trying to point to StarterGUI. When a player joins, all StarterGuis will clone and parent itself to the PlayerGui, so attempting to change the StarterGui itself won’t change anything for the Player’s side. You can either:
Use a whole bunch of “Parent”s until you get to the specified frame.
Replace the Script with a LocalScript, and point to the LocalPlayer’s PlayerGui.
If you want to follow Method 1, then you can rewrite the variable back’s path with:
local back = script.Parent.Parent
If you want to follow Method 2, then convert the ServerScript to a LocalScript, and rewrite for the variables:
local Player = game.Players.LocalPlayer
local back = Player.PlayerGui.ApplyGui.BackFrame.SideFrame.Info
It’s recommended needed for you to code all this in a LocalScript, regardless whether you follow Method 1 or 2, as this will help speed up the server due to this supposed to be client-replicated.
Just as @Deb0rahAliWilliams said, you’re using the startergui rather than the playergui. Also, server scripts don’t work in client services, so you’ll always need to use a localscript.
Thanks so much! I used method 2 and it did work but instead of using local Player = game.Players.LocalPlayer
could I use local Player = game:GetService("Players").LocalPlayer ?
Im not exactly sure how it works but I did read in another topic that using GetService works faster, not sure if its true.
In this case, because the Player service is not being renamed, and if your code is staying private to your game, then there is no need to place :GetService(). You still can, but it won’t make much of a difference in terms of speed.