This function should change the cube and light color randomly every half second but when I call it, nothing happens.
--in a module
function customFuncs.TestCube(model:Model)
local cube : Part = model.Part;
local light : PointLight = cube.PointLight
while wait(0.5) do
local color = BrickColor.random();
cube.BrickColor = color;
light.Color = cube.Color;
end
end
I’m calling the function with this function
--also in a module
function module:PlaceItem(itemId, player:Player, modelCFrame)
local model = invRef.gameItems[itemId].ItemModel;
if not model then warn("id:"..itemId.." missing model"); return; end
local clone = model:Clone();
clone:SetAttribute("Owner", player.UserId);
clone:PivotTo(modelCFrame);
clone.Parent = workspace;
invRef.gameItems[itemId].Function(model, itemId); --called here
end
That function is being called here in a server script
brickcolor has a property called .Color returns color3 formatted so you can use that for the light I guess instead of putting a brickcolor which is not admited assuming the light uses color3
printing the colors of the cube and light and it’s right… but they still aren’t actually changing color
function customFuncs.TestCube(model:Model)
local cube : Part = model.Part;
local light : PointLight = cube.PointLight;
while wait(0.5) do
local color = BrickColor.random().Color;
cube.Color = color;
light.Color = cube.Color;
print("cube:", cube.Color, "light:", light.Color)
end
end
it has to be a roblox bug or something because this is really weird
well i ran out of ideas for you… i also dont know why this is happening, does it just like print out, but never actually changes the color? if so thats pretty weird
well the only possible reason for this is that you arent calling this function properly, as the instance/model ur looking for isnt correct, check for any misspelling
edit: if you’ve done all correct, the only possible reason i could think of would to be restart studio, if that doesnt work uninstall and install it back
function customFuncs.TestCube(model: Model)
local cube: Part = model.Part
local light: PointLight = cube.PointLight
task.spawn(function()
while task.wait(0.5) do -- task.wait > wait
local color = BrickColor.Random().Color -- for some reason, roblox likes PascalCasing more than camelCasing, also yes you can do BrickColor.new().Color
cube.Color = color -- fun fact: semicolon on every line isn't needed
light.Color = color
end
end) -- using task.spawn allows other code to run after you call this function
end
I’m sorry everyone, I was right. It is embarrassing. I was passing the model in replicated storage to the function instead of the clone… Thanks for trying lol