Custom Cursors for ShiftLock & Normal

How would I change the shift lock cursor and the default cursor?

I want both to be custom, I know that changing the player module will replace the shift lock switch, but if i change the custom cursor, that custom cursor would override the shift lock icon.

-- // Services

-- External services
local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")

-- Internal services
local playersService = game:GetService("Players")

-- // Variables

-- Player variables
local player = playersService.LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")

local camera = workspace.CurrentCamera

-- UI variables
local cursorUI = script.Parent
local cursor = cursorUI:WaitForChild("Cursor")
local clicked = cursor:WaitForChild("Clicked")

-- Values
local target = nil

-- // Functions
userInputService.MouseIconEnabled = false

local function tweenCursor(state)

	local tween = nil

	if state == true then

		tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
			ImageColor3 = Color3.fromRGB(255, 82, 82),
			Size = UDim2.new(0.025, 0, 0.050, 0)
		})

	elseif state == false then

		tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
			ImageColor3 = Color3.fromRGB(255, 255, 255),
			Size = UDim2.new(0.025, 0, 0.050, 0)
		})

	end

	tween:Play()

	spawn(function()
		tween.Completed:Wait()
		tween:Destroy()
	end)

end

local function clickedEvent()
	clicked:TweenSize(UDim2.fromScale(1, 1), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true, nil)

	local tween = tweenService:Create(clicked, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {BackgroundTransparency = 1})
	tween:Play()

	spawn(function()
		tween.Completed:Wait()
		tween:Destroy()

		clicked.Size = UDim2.fromScale(0, 0)
		clicked.BackgroundTransparency = 0
	end)
end

local function updateCursor()

	cursor.Position = UDim2.new(0, mouse.X, 0, mouse.Y)

	target = mouse.Target

	if target ~= nil and target:FindFirstChildOfClass("ClickDetector") then
		local click = target:FindFirstChildOfClass("ClickDetector")

		if (character.HumanoidRootPart.Position - target.Position).Magnitude < click.MaxActivationDistance then
			tweenCursor(true)
		else
			tweenCursor(false)
		end
	else
		tweenCursor(false)
	end

end

-- // Connections
mouse.Button1Down:Connect(function()
	if target ~= nil and target:FindFirstChild("ClickDetector") then
		print("Clicked click detector")

		clickedEvent()
	end
end)

runService.RenderStepped:Connect(updateCursor)
2 Likes