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

Function not working?

Asked by
Omarstein 100
10 years ago

This is part of a script I created...

01function createLeaderboard()
02    iframe = Instance.new("Frame", script.Parent.Game)
03    iframe.Name = "IFrame"
04    iframe.Size = UDim2.new(0.3,0,0.5,0)
05    iframe.Position = UDim2.new(0.5,0,0.5,0)
06    iframe.BackgroundTransparency = 1
07    mframe = Instance.new("Frame", iframe)
08    mframe.Name = "MFrame"
09    mframe.BackgroundColor3 = Color3.new(102,0,0)
10    mframe.BorderSizePixel = 5
11    mframe.BorderColor3 = Color3.new(255,0,0)
12    mframe.Size = UDim2.new(1,0,1,0)
13    mframe.Position = UDim2.new(-0.5,0,-0.5,0)
14end

The problem is when i play solo or online the colors aren't set to what i set them to... they change to:

BackgroundColor3 = 26010, 0, 0 ---- BorderColor3 = 5025, 0, 0

--EDIT-- FULL SCRIPT:

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse()
03 
04function createLeaderboard()
05    iframe = Instance.new("Frame", script.Parent.Game)
06    iframe.Name = "IFrame"
07    iframe.Size = UDim2.new(0.3,0,0.5,0)
08    iframe.Position = UDim2.new(0.5,0,0.5,0)
09    iframe.BackgroundTransparency = 1
10    mframe = Instance.new("Frame", iframe)
11    mframe.Name = "MFrame"
12    mframe.BackgroundColor3 = Color3.new(102,0,0)
13    mframe.BorderSizePixel = 5
14    mframe.BorderColor3 = Color3.new(255,0,0)
15    mframe.Size = UDim2.new(1,0,1,0)
View all 28 lines...
0
Do you have anything calling the function? Providing where you call it might help. Necrorave 560 — 10y
0
Posted full script Omarstein 100 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

Color values range from 0 - 255, but when you use them in a Color3, they range from 0 - 1. Intead of saying Color3.new(255,0,0), you have to say Color3.new(1,0,0). Basically divide every color value in the Color3 by 255.

1local R = 255
2local G = 0
3local B = 0
4NewColor = Color3.new(R / 255, G / 255, B / 255)

Hope this helped!

Note: When you say Color3.new(102,0,0), it should actually be Color3.new(102/255,0,0)

Ad

Answer this question