Cursor Rotating when hovered on clickable

Hello! im going into a state of mentality with this issue.
What im trying to achieve is to get a cursor to rotate when hovering over a clickable (literally a rip off from blackout revival)
i have tried to use tweens, but i get this issue

Players.QZJ0.PlayerGui.ScreenGui.ImageLabel.LocalScript:39: attempt to call missing method ‘Create’ of table

here is the script i tried using -

local ClickableTween = game:GetService("TweenService")
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

local descendants = workspace:GetDescendants()

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Cursor = script.Parent
local Last = Vector2.new(0, 1)


local function UpdateCursor()
	local Position = UserInputService:GetMouseLocation()
	local Delta = Last - Position


	Cursor.Position = UDim2.new(-0.0025, Position.X, -0.0525, Position.Y)

	Last = Position
end

UserInputService.MouseIconEnabled = false
RunService.Heartbeat:Connect(UpdateCursor)


local descendants = game.StarterGui:GetDescendants()

local tweeninfo = TweenInfo.new(
	0.2,
	Enum.EasingStyle.Circular,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local hovertween = TweenInfo:Create(Cursor, TweenInfo, {Rotation = 45})
local hovertween2 = TweenInfo:Create(Cursor, TweenInfo, {Size = {0,13},{0,13}})


local unhovertween = TweenInfo:Create(Cursor, TweenInfo, {Rotation = 0})
local unhovertween2 = TweenInfo:Create(Cursor, TweenInfo, {Size = {0,11},{0,11}})


for i, descendant in pairs(descendants) do
	if descendant:IsA("ImageButton") then
		descendant.MouseEnter:Connect(function()
			hovertween:Play()
			hovertween2:Play()
		end)
		descendant.MouseLeave:Connect(function()
			unhovertween:Play()
			unhovertween2:Play()
		end)
	end
end	
		

its not the most practical script, and im pretty new, so any help is APPRECIATEDDDD!!!

3 Likes

You’re using :Create with tweeninfo. You have to do Tweenservice:Create.

Great! but unfortunately now i get another error.

“Unable to cast Dictionary to TweenInfo”

part of the code in which is says

local hovertween = TweenService:Create(Cursor, TweenInfo, {Rotation = 45})
local hovertween2 = TweenService:Create(Cursor, TweenInfo, {Size = {0,13},{0,13}})


local unhovertween = TweenService:Create(Cursor, TweenInfo, {Rotation = 0})
local unhovertween2 = TweenService:Create(Cursor, TweenInfo, {Size = {0,11},{0,11}})

As tweeninfo information for the tweens you are using the library of functions Tweeninfo, the same one you created the tweeninfo variable. You should be using the “tweeninfo” variable.

im sorry im pretty dumb, can you just explain it in stupid language?

local hovertween = TweenService:Create(Cursor, tweeninfo, {Rotation = 45})
local hovertween2 = TweenService:Create(Cursor, tweeninfo, {Size = {0,13},{0,13}})


local unhovertween = TweenService:Create(Cursor, tweeninfo, {Rotation = 0})
local unhovertween2 = TweenService:Create(Cursor, TweenInfo, {Size = {0,11},{0,11}})

Corrected code.

same error shows, Unable to cast to Dictionary

Hey, sorry, for the “unhovertween2” change the word “TweenInfo” with “tweeninfo”

altought the code now shows the error on hovertween2 and probably unhovertween2

What is the error? Also, try putting a :Play at the end of the first tween and check if it plays.

the first Tween plays, but the second one has an error,

the error is

Unable to cast to Dictionary - Client - LocalScript:41

Try setting this as the hovertween2 properties.

{Size = Udim2.new(0, 13, 0, 13)}

it says

Players.QZJ0.PlayerGui.ScreenGui.ImageLabel.LocalScript:41: attempt to index nil with ‘new’

Hey, sorry, but I’m on mobile so I’m a bit slow. Can you show me your code again?

ok so now it works, although no errors, the

for i, descendant in pairs(descendants) do
	if descendant:IsA("ImageButton") then
		descendant.MouseEnter:Connect(function()
			hovertween:Play()
			hovertween2:Play()
		end)
		descendant.MouseLeave:Connect(function()
			unhovertween:Play()
			unhovertween2:Play()
		end)
	end
end	
		
		

doesnt play

Hey, can you post your code again? I need to be able to tell which variables are what.

local ClickableTween = game:GetService("TweenService")
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

local descendants = workspace:GetDescendants()

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Cursor = script.Parent
local Last = Vector2.new(0, 1)


local function UpdateCursor()
	local Position = UserInputService:GetMouseLocation()
	local Delta = Last - Position


	Cursor.Position = UDim2.new(-0.0025, Position.X, -0.0525, Position.Y)

	Last = Position
end

UserInputService.MouseIconEnabled = false
RunService.Heartbeat:Connect(UpdateCursor)

local TweenService = game:GetService("TweenService")

local descendants = game.StarterGui:GetDescendants()

local tweeninfo = TweenInfo.new(
	0.2,
	Enum.EasingStyle.Circular,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local hovertween = TweenService:Create(Cursor, tweeninfo, {Rotation = 45})
local hovertween2 = TweenService:Create(Cursor, tweeninfo, {Size = UDim2.new(0, 13, 0, 13)})


local unhovertween = TweenService:Create(Cursor, tweeninfo, {Rotation = 0})
local unhovertween2 = TweenService:Create(Cursor, tweeninfo, {Size = UDim2.new(0, 13, 0, 13)})


for i, descendant in pairs(descendants) do
	if descendant:IsA("ImageButton") then
		descendant.MouseEnter:Connect(function()
			hovertween:Play()
			hovertween2:Play()
		end)
		descendant.MouseLeave:Connect(function()
			unhovertween:Play()
			unhovertween2:Play()
		end)
	end
end	
		
		

I think it might be because you are updating the cursor every frame, so when the tweens are played, they get overwritten by the .Heartbeat function.

yeah but then what other option do i have.

“nope that isn’t the problem, i removed the heartbeat and still does not work”

Well, you could just add a
local debounce = false
And put an
if (not debounce) then
In the update cursor function, and put an
debounce = true
when you play the tweens.