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
9 years ago

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)
0
Do you have anything calling the function? Providing where you call it might help. Necrorave 560 — 9y
0
Posted full script Omarstein 100 — 9y

1 answer

Log in to vote
2
Answered by 9 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.

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)

Ad

Answer this question