-
I want to have this script not make the color change when you join
-
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
-
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.
Code
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
Normal.MouseButton1Click:Connect(function()
local color = Enum.Font.Gotham
script.Parent.DisplayName.Font = Enum.Font.Gotham
FontEvent:FireServer(color)
end)
Bold.MouseButton1Click:Connect(function()
local color = Enum.Font.GothamBold
script.Parent.DisplayName.Font = Enum.Font.GothamBold
FontEvent:FireServer(color)
end)
SemiBold.MouseButton1Click:Connect(function()
local color = Enum.Font.GothamSemibold
script.Parent.DisplayName.Font = Enum.Font.GothamSemibold
FontEvent:FireServer(color)
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Fetch the thumbnail
wait(5)
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 = Vector2.new(
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 = ColorSequence.new{
ColorSequenceKeypoint.new(0, hsv),
ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}
end
colourWheel.MouseButton1Down:Connect(function()
buttonDown = true
end)
darknessPicker.MouseButton1Down:Connect(function()
movingSlider = true
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
buttonDown = false
movingSlider = false
end)
uis.InputChanged:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
local mousePos = uis:GetMouseLocation() - Vector2.new(0, game:GetService("GuiService"):GetGuiInset().Y)
local centreOfWheel = Vector2.new(colourWheel.AbsolutePosition.X + (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 = UDim2.new(0, mousePos.X - colourWheel.AbsolutePosition.X, 0, mousePos.Y - colourWheel.AbsolutePosition.Y)
elseif movingSlider then
darknessSlider.Position = UDim2.new(darknessSlider.Position.X.Scale, 0, 0,
math.clamp(
mousePos.Y - darknessPicker.AbsolutePosition.Y,
0,
darknessPicker.AbsoluteSize.Y)
)
end
local hi = colourDisplay.TextColor3
RemoteEventLocation:FireServer(hi)
updateColour(centreOfWheel)
end)