Script Fires Function When Player Joins

  1. I want to have this script not make the color change when you join

  2. I have a script that keeps firing when a person joins and I would like to have it so that it will only work if a player actually move the color picker

  3. I’ve tried making it a GetPropertyChanged and tried to make is so that if someone changes the colorDisplay it triggers a function and to not make it fire when a player just joins.

The script keeps updatingColor and I would like to have it so that it only works when a player actually moves the position of it. It keeps doing it when I join which messes up alot of my other code. Any guidance on what I did wrong would mean alot.

local wheelPicker = colourWheel:WaitForChild("Picker")

local darknessPicker = script.Parent:WaitForChild("DarknessPicker")
local darknessSlider = darknessPicker:WaitForChild("Slider")

local colourDisplay = script.Parent:WaitForChild("DisplayName")

local Normal = script.Parent:WaitForChild("Normal")
local Bold = script.Parent:WaitForChild("Bold")
local SemiBold = script.Parent:WaitForChild("SemiBold")

local FontEvent = game.ReplicatedStorage.SetFont

local RemoteEventLocation = game.ReplicatedStorage.SetColour

local uis = game:GetService("UserInputService")

local buttonDown = false
local movingSlider = false


	local color = Enum.Font.Gotham
	script.Parent.DisplayName.Font = Enum.Font.Gotham


	local color = Enum.Font.GothamBold
	script.Parent.DisplayName.Font = Enum.Font.GothamBold


	local color = Enum.Font.GothamSemibold
	script.Parent.DisplayName.Font = Enum.Font.GothamSemibold

local Players = game:GetService("Players")

local player = Players.LocalPlayer

-- Fetch the thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

-- Set the ImageLabel's content to the user thumbnail
local imageLabel = script.Parent.Thumbnail
imageLabel.Image = content

script.Parent.DisplayName.Text = game.Players.LocalPlayer.DisplayName
script.Parent.RankName.Text = game.Players.LocalPlayer.Name

local Player = game.Players.LocalPlayer -- assuming this is in a LocalScript
local groupId = 7354329

local PlayerRankInGroup = Player:GetRoleInGroup(groupId)
script.Parent.RankText.Text = PlayerRankInGroup

local function updateColour(centreOfWheel)

	local colourPickerCentre =
		colourWheel.Picker.AbsolutePosition.X + (colourWheel.Picker.AbsoluteSize.X/2),
		colourWheel.Picker.AbsolutePosition.Y + (colourWheel.Picker.AbsoluteSize.Y/2)
	local h = (math.pi - math.atan2(colourPickerCentre.Y - centreOfWheel.Y, colourPickerCentre.X - centreOfWheel.X)) / (math.pi * 2)

	local s = (centreOfWheel - colourPickerCentre).Magnitude / (colourWheel.AbsoluteSize.X/2)

	local v = math.abs((darknessSlider.AbsolutePosition.Y - darknessPicker.AbsolutePosition.Y) / darknessPicker.AbsoluteSize.Y - 1)

	local hsv = Color3.fromHSV(math.clamp(h, 0, 1), math.clamp(s, 0, 1), math.clamp(v, 0, 1))

	colourDisplay.TextColor3 = hsv
	darknessPicker.UIGradient.Color ={, hsv),,, 0, 0))

	buttonDown = true

	movingSlider = true


	if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end

	buttonDown = false
	movingSlider = false


	if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end

	local mousePos = uis:GetMouseLocation() -, game:GetService("GuiService"):GetGuiInset().Y)

	local centreOfWheel = + (colourWheel.AbsoluteSize.X/2), colourWheel.AbsolutePosition.Y + (colourWheel.AbsoluteSize.Y/2))

	local distanceFromWheel = (mousePos - centreOfWheel).Magnitude

	if distanceFromWheel <= colourWheel.AbsoluteSize.X/2 and buttonDown then

		wheelPicker.Position =, mousePos.X - colourWheel.AbsolutePosition.X, 0, mousePos.Y - colourWheel.AbsolutePosition.Y)

	elseif movingSlider then

		darknessSlider.Position =, 0, 0, 
				mousePos.Y - darknessPicker.AbsolutePosition.Y, 
	local hi = colourDisplay.TextColor3
1 Like

What color? Can you give some screenshots to show what you’re talking about?

Sure thing! Sorry if I was unclear but every time I join into the game it changes a BillboardGui.Textlabel’s TextColor3. I’m a bit confused as to what I’m doing wrong and why this script is making this happen. It should only work when the colourWheel.Picker’s position changes

So reading the script, it looks like you want to have a color wheel players can use to change their name color. Is this color wheel visible at all times?

The updateColour function is the one which changes the name’s text color. The InputChanged event’s function on line 113 is supposed to call this function when the mouse moves. Try joining the game and not moving your mouse at all. As soon as you move your mouse, it should immediately change to white.

The reason for this is that you are not specifying that the mouse movement actually occurred inside of the color wheel. After ensuring the input was a mouse movement on line 115, you don’t have any checks that would otherwise prevent updateColour from being called. Perhaps move the call from line 141 (always called when moving the mouse) to line 128 (only called when distanceFromWheel <= colourWheel.AbsoluteSize.X/2 is true, which is functionally similar to a collision check).

I am not sure what the purpose of moving the wheel picker on line 127 is, or really what a wheel picker even is. Providing a .rbxl file would give us more information to help you.

1 Like

I’ve gone ahead and tested the game, you are correct. If I keep my mouse still it does not fire.
This color picker is from a youtube tutorial which is why I’m having trouble finding the problem. The script I have requires a lot of different things so It wouldn’t work if I just provided it.


Model From The Tutorial (Model Goes In Starter Gui)

Maybe try adding a wait(3) at the beginning of the script?

I’ve tried that and then it automatically makes the nametag white after the wait.

At the end of your piece of code, it activates the remote event and updateColour function without ever checking if the mouse button is down or moving the slider. I don’t know if this is the problem or not though.

A YouTube tutorial script … I see, I have to admit I didn’t know these existed outside series dedicated to teaching scripting. If you don’t want to change the structure of the script, you should just add a stipulation somewhere in the InputChanged function that makes it so that it only tries changing colors when the menu is open. Something like if menu.Visible == false then return end right before or right after the MouseMovement check.

It isn’t the problem. I added stipulation and that seemed to fix the problem. Thank you anyways!

That seemed to work, I appreciate the help!