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

Why color of the image is not changing?

local player = game.Players.LocalPlayer 
local Mouse = player:GetMouse() 
local Gui = game.StarterGui.ScreenGui.Base 

Mouse.Button1Down:connect(function() 
	Gui.Text.Button.ImageColor3 = Color3.fromRGB(20, 200, 20) 
end)

1 comment

0

(Wrapped your code in a code block - it's the little "Lua" button to the right of bold/italics/etc.)

2 answers

The problem is that the player never interacts with things in StarterGui - Roblox clones things in StarterGui into each player's PlayerGui.

Change = game.StarterGui to game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Base") (or some people just put the script in Base and then they can say = script.Parent)

Note that a major flaw of all this is having to use WaitForChild. If you instead put the guis into a folder like ReplicatedStorage, you can move or clone the guis yourself and then all the instances will be available immediately (best used in conjunction with a LocalScript in StarterPlayerScripts where the ScreenGuis are told to not reset when the player dies; this only works if your script adapts to how the player's Character/Humanoid/etc may change over time). If you use this technique, since you'll still want to see your guis in StarterGui while working on them, you can use a Script that simply moves all StarterGui children into the designated folder when the server starts up. (In the event you run into any errors, you might need a single WaitForChild on the top-level guis, but unlike the standard technique, you don't need to use WaitForChild on each child after that!)

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