Hi guys I'm trying to change the colour of a block by selecting creating a colour on a Gui, I have a script parented to the part I'm wanting to effect:
local players = game:GetService("Players") players.PlayerAdded:connect(function (player) wait(1) --this is just to let the player load, it'll be cleaner when im done haha local p_colour = require(player.PlayerGui.Gui.TextButton.ModuleScript).colour() print(p_colour) script.Parent.Color = Color3.new(p_colour) end)
And the module script it is referring to is:
local _M = {} function _M.colour(p_colour) p_colour = script.Parent.BackgroundColor3 print(p_colour) return(p_colour) end return _M
both of the print value out put the correct Color3 value (255,51,93) but the effected part always changed to black (0,0,0).
I've been trying to fix this for ages and it's probably something stupid that i'm missing...
Thanks for your time!
The ModuleScript uses script.Parent... I'm not sure if you should be using that - I doubt script.Parent will swap over to the parent of the script calling it.
Also...
ModuleScript)
the parenthese.
Also an improvement to your script:
Replace wait(1)
with player.CharacterAdded:Wait()
; it'll start up the stuff the instant the character is added.
Although about the thing with it turning black... I don't know... unless it might have to do with the ModuleScript's parent.
"If the .color()
returns a color3, you can remove the Color3.new() on line 6"
-theCJarmy7
[CLOSED]