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

Why color of the image is not changing?

Asked by 3 years ago
Edited by chess123mate 3 years ago
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)
0
(Wrapped your code in a code block - it's the little "Lua" button to the right of bold/italics/etc.) chess123mate 5873 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Any errors?

0
none trocindavid 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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!)

Answer this question