Want to stay connected to the Scripting Helpers community and get real-time help? Join the Scripting Helpers Discord Server!
Ad
Log in to vote
0

Color part does not work and breaks the whole thing! Why is it doing that?

Asked by
moo1210 16
3 months ago

Can anyone help?



local model = script.Parent local ticker = { guis = {}, config = model.Configurations, adornees = {}, length = 0, dist = 0, textlengthpx = 0 } -- -- util functions function resizesurfaces() local factor = ticker.config.PixelDensityFactor.Value for gui, info in next, ticker.guis do local adornee = gui.Adornee or gui.Parent local surfacelength = math.max(math.max(adornee.Size.x, adornee.Size.z), (ticker.textlengthpx+ticker.config.MinPixelsBetweenPhrases.Value)/factor) gui.CanvasSize = Vector2.new(surfacelength, adornee.Size.y)*factor ticker.adornees[adornee] = true end end function settext(text) for gui, info in next, ticker.guis do for index, label in next, info.labels do label.Text = text ticker.textlengthpx = label.TextBounds.X end end resizesurfaces() end --- broken part function settextcolor(color) for gui, info in next, ticker.guis do for index, label in next, info.labels do label.TextColor3 = Color3.fromRGB(script.Parent.Configurations.TextColor.Value.r,script.Parent.Configurations.TextColor.Value.g,script.Parent.Configurations.TextColor.Value.b) end end end --- end of broken part function setbackgroundcolor(color) for gui, info in next, ticker.guis do gui.Back.BackgroundColor3 = color.Color end end function setbackgroundtransparency(transparency) for gui, info in next, ticker.guis do gui.Back.BackgroundTransparency = transparency end end function settextstroketransparency(transparency) for gui, info in next, ticker.guis do for index, label in next, info.labels do label.TextStrokeTransparency = transparency end end end function settextstrokecolor(color) for gui, info in next, ticker.guis do for index, label in next, info.labels do label.TextStrokeColor3 = color.Color end end end -- -- setup code for index, obj in next, model:GetChildren() do if obj:IsA'SurfaceGui' then obj.Parent=nil wait() obj.Parent=model -- weird... local index = tonumber(obj.Name) if index then ticker.guis[obj] = { index = index, start = ticker.length, length = 0, labels = {} } local surfacesize = (Vector3.new(1,1,1) - Vector3.FromNormalId(obj.Face)) * (obj.Adornee or obj.Parent).Size ticker.guis[obj].length = math.max(surfacesize.x, surfacesize.z) ticker.length = ticker.length + ticker.guis[obj].length end end end for gui, info in next, ticker.guis do for index=1, 3 do local textlabel = Instance.new('TextLabel', gui.Back) textlabel.BackgroundTransparency = 1 textlabel.Size = UDim2.new(1, 0, 1, 0) textlabel.Text = ticker.config.Text.Value textlabel.TextColor3 = ticker.config.TextColor.Value.Color textlabel.Font = Enum.Font.SourceSansBold textlabel.FontSize = Enum.FontSize.Size48 textlabel.TextXAlignment = Enum.TextXAlignment.Left ticker.textlengthpx = textlabel.TextBounds.X info.labels[index] = textlabel end end resizesurfaces() -- -- main functions function update(delta) ticker.dist = (ticker.dist + (delta*-ticker.config.Speed.Value))%ticker.length for gui, info in next, ticker.guis do local alpha = ticker.dist/ticker.length info.labels[1].Position = UDim2.new( alpha-1, 0, 0, 0 ) info.labels[2].Position = UDim2.new( alpha, 0, 0, 0 ) info.labels[3].Position = UDim2.new( alpha+1, 0, 0, 0 ) end end -- -- main loop local cache = { adorneesizes = {} } ticker.config.Text.Changed:connect(settext) ticker.config.TextColor.Changed:connect(settextcolor) ticker.config.BackgroundColor.Changed:connect(setbackgroundcolor); setbackgroundcolor(ticker.config.BackgroundColor.Value) ticker.config.BackgroundTransparency.Changed:connect(setbackgroundtransparency); setbackgroundtransparency(ticker.config.BackgroundTransparency.Value) ticker.config.TextStrokeTransparency.Changed:connect(settextstroketransparency); settextstroketransparency(ticker.config.TextStrokeTransparency.Value) ticker.config.TextStrokeColor.Changed:connect(settextstrokecolor); settextstrokecolor(ticker.config.TextStrokeColor.Value) ticker.config.PixelDensityFactor.Changed:connect(resizesurfaces) ticker.config.MinPixelsBetweenPhrases.Changed:connect(resizesurfaces) while true do update(wait()) local cacheSizeIsCorrect = true for adornee in next, ticker.adornees do if cache.adorneesizes ~= adornee.Size then cache.adorneesizes = adornee.Size cacheSizeIsCorrect = false end end if not cacheSizeIsCorrect then resizesurfaces() end end
0
Can you tell us the result and the errors? It’s hard to find the problem with a complex script and the little info you gave us. Denny9876 942 — 3mo
0
Have you tried changing Color3.fromRGB to Color3.new() on line 41, as Color3Values use numbers from 0 to 1 UgOsMiLy 964 — 3mo

Answer this question