Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Function not working?

This is part of a script I created...

function createLeaderboard()
	iframe = Instance.new("Frame", script.Parent.Game)
	iframe.Name = "IFrame"
	iframe.Size = UDim2.new(0.3,0,0.5,0)
	iframe.Position = UDim2.new(0.5,0,0.5,0)
	iframe.BackgroundTransparency = 1
	mframe = Instance.new("Frame", iframe)
	mframe.Name = "MFrame"
	mframe.BackgroundColor3 = Color3.new(102,0,0)
	mframe.BorderSizePixel = 5
	mframe.BorderColor3 = Color3.new(255,0,0)
	mframe.Size = UDim2.new(1,0,1,0)
	mframe.Position = UDim2.new(-0.5,0,-0.5,0) 
end

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:


local player = game.Players.LocalPlayer 
local mouse = player:GetMouse()

function createLeaderboard()
	iframe = Instance.new("Frame", script.Parent.Game)
	iframe.Name = "IFrame"
	iframe.Size = UDim2.new(0.3,0,0.5,0)
	iframe.Position = UDim2.new(0.5,0,0.5,0)
	iframe.BackgroundTransparency = 1
	mframe = Instance.new("Frame", iframe)
	mframe.Name = "MFrame"
	mframe.BackgroundColor3 = Color3.new(102,0,0)
	mframe.BorderSizePixel = 5
	mframe.BorderColor3 = Color3.new(255,0,0)
	mframe.Size = UDim2.new(1,0,1,0)
	mframe.Position = UDim2.new(-0.5,0,-0.5,0) 
end

mouse.KeyDown:connect(function(key)
	if key == "q" then
		createLeaderboard()
	end
end)
mouse.KeyUp:connect(function(key)
	if key == "q" then
		script.Parent.Game.IFrame:Destroy()
	end
end)

2 comments

0

Do you have anything calling the function? Providing where you call it might help.

0

Posted full script

1 answer

✓ Accepted answer

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.

local R = 255
local G = 0
local B = 0
NewColor = 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)

This discussion is preserved as it was. New answers, comments, and votes are closed.