Mouse.Icon is not changing the cursor

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am trying to change the cursor when a tool is equipped.

  2. What is the issue? The cursor remains the same.

  3. What solutions have you tried so far? Currently, the tools are being issued to players from the server when they join, since a datastore must first determine if they own each weapon. When they equip these weapons everything works fine except that the cursor does not change. When I tried just placing the tools in StarterPack, the code worked and the cursor changed correctly.

Mouse.Icon = "rbxassetid://9622710009"

Please Help. Thank you.

3 Likes

Maybe check if the local player had it and then it will change?

I’m not sure what you mean. Could you elaborate please?

Can you send the entire script, including its world-postion, script type (must be local), and any possible errors? Thanks!

Sure. Here is the client script.

--#Palmtreeninja2
wait(2)
--#Variables
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local Gun = script.Parent.Parent
local BulletOrigin = Gun:WaitForChild("BulletOrigin")
local AnimationFolder = Gun:WaitForChild("Animations")

--#Animations
local Draw = AnimationFolder:WaitForChild("Draw")
local Idle = AnimationFolder:WaitForChild("Idle")
local Aim = AnimationFolder:WaitForChild("Aim")
local Fire = AnimationFolder:WaitForChild("Fire")
local Reload = AnimationFolder:WaitForChild("Reload")
local Quickshot = AnimationFolder:WaitForChild("Quickshot")
local Holster = AnimationFolder:WaitForChild("Holster")

local DrawAnimation = Humanoid:LoadAnimation(Draw)
local HolsterAnimation = Humanoid:LoadAnimation(Holster)
local IdleAnimation = Humanoid:LoadAnimation(Idle)
local AimAnimation = Humanoid:LoadAnimation(Aim)
local FireAnimation = Humanoid:LoadAnimation(Fire)
local QuickshotAnimation = Humanoid:LoadAnimation(Quickshot)
local ReloadAnimation = Humanoid:LoadAnimation(Reload)

--#Services
local UIS = game:GetService("UserInputService")
local FireKey = Enum.UserInputType.MouseButton1

--#Values
local Equipped = false
local Aiming = false
local Recoiling = false
local RecoilTime = 0.2
local Reloading = false
local BulletsCapacity = 50

--#Events
local EventsFolder = Gun:WaitForChild("Events")
local CockedEvent = EventsFolder:WaitForChild("Cocked")
local ShotEvent = EventsFolder:WaitForChild("Shot")
local ReloadedEvent = EventsFolder:WaitForChild("Reloaded")
local EquippedEvent = EventsFolder:WaitForChild("Equipped")
local HolsteredEvent = EventsFolder:WaitForChild("Holstered")
local CreateBulletEvent = game.ReplicatedStorage.ShotFired

--#UI
local HUD = Gun.HUD:Clone()

--#Functions
local function reload()
	if Equipped then
		Reloading = true
		script.Parent.Parent.Sounds.Reload:Play()
		ReloadAnimation:Play()
		ReloadAnimation.Stopped:Wait()
		BulletsCapacity = 50
		HUD.Ammo.Amount.Text = "50 / 50"
		Reloading = false
	end
end

local function Equip()
	Equipped = true
	Aiming = true
	game.Players.LocalPlayer:GetMouse().Icon = script.Parent.Parent.ZipgunRhetical.Texture
	print(Mouse.Icon)
	EquippedEvent:FireServer()
	CockedEvent:FireServer()
	HUD.Parent = Player.PlayerGui
	Player.CameraMinZoomDistance = 0.5
	Player.CameraMaxZoomDistance = 0.5
	Character.GunBelt.Dashes.Transparency = 1
	Character.GunBelt.Frame.Transparency = 1
	Character.GunBelt.Magazine.Transparency = 1
	Character.GunBelt.Slide.Transparency = 1
	Character.GunBelt.Trigger.Transparency = 1
	Humanoid.CameraOffset = Vector3.new(0,0,-1)
	DrawAnimation:Play()
	DrawAnimation.Stopped:Wait()
	AimAnimation:Play()
end

local function UnEquip()
	Equipped = false
	game.Players.LocalPlayer:GetMouse().Icon = ""
	HolsteredEvent:FireServer()
	HUD.Parent = Gun
	Player.CameraMinZoomDistance = 0.5
	Player.CameraMaxZoomDistance = 30
	Character.GunBelt.Dashes.Transparency = 0
	Character.GunBelt.Frame.Transparency = 0
	Character.GunBelt.Magazine.Transparency = 0
	Character.GunBelt.Slide.Transparency = 0
	Character.GunBelt.Trigger.Transparency = 0
	Humanoid.CameraOffset = Vector3.new(0,0,0)
	AimAnimation:Stop()
	HolsterAnimation:Play()
	Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
end

local function Shoot()
	if Equipped and not Recoiling and not Reloading and BulletsCapacity >= 1 then
		local Target = Mouse.Hit.p
		if Aiming then
			BulletsCapacity -= 1
			ShotEvent:FireServer()
			Recoiling = true
			FireAnimation:Play()
			CreateBulletEvent:FireServer(Target,BulletOrigin.Position)
			workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(.5),0,0)
			wait(RecoilTime)
			Recoiling = false
			HUD.Ammo.Amount.Text = BulletsCapacity .. " / 50"
		end
	end
end

--#Run
Gun.Equipped:Connect(Equip)
Gun.Unequipped:Connect(UnEquip)

UIS.InputBegan:Connect(function(input,chatting)
	if not chatting and input.UserInputType == FireKey then
		Shoot()
	end
	if not chatting and input.KeyCode == Enum.KeyCode.R then
		reload()
	end
end)

UIS.InputEnded:Connect(function(input,chatting)
	if not chatting and input.UserInputType == FireKey then
		Shoot()
	end
end)

Humanoid.Died:Connect(UnEquip)

Everything else is working fine. It’s just like the script is skipping over the line about the mouse icon. I’ve also noticed that it works in studio, but not in the game.

Disable RequiresHandle on tool properties or add a handle part on the tool

1 Like

How does that have anything to do with a mouse cursor?

If tool was in Replicated and script was in tool, it will be worked fine.

Ahh ok, I will try that. So far I’ve been having the tool be in ServerScriptService. Didn’t know there was a difference.

1 Like

The tool doesn’t know on which to follow, when the part is now visible? or when the tool has been used. So when you create a tool it enables RequiresHandle already. So the equipped/unequiped/active function will run once the part is visible (if RequiresHandle exist) if there’s no part named “handle” its clueless if it’s equipped.

i’ll upload a video if you don’t believe me: 2022 05 23 13 18 25 - YouTube

Video Explanation Notes:
The first tool is the tool where the RequiresHandle is enabled
The second tool is the tool where the RequiresHandle is disabled

Bro I’m not trying to sound rude, but you are on a completely different subject. The tool works fine. The gun fires, reloads, equips, and unequips, has a handle, does all the right sounds, animations, effects, etc… I’m just talking about the cursor.

1 Like

are you sure that id exists.(sorry ik i should cheeck myseelf but im not in studio so i asked.).
Try putting the id in a image label and if it changes to ur deesired imagee then its some other problem else check your string.

Currently I am using a decal. Will give an imagelabel a shot. Thanks.

No im asking does the image apears whether if its a decal or image label.

The images appear when I test in studio. After it worked in studio I updated the game and went to play it on the actual roblox page, but it didnt work.

Ok then maybe its not yet moderated hence the icon doesnt update. Try using another id. If that works then ur id isnt modeerated.

I made the icons more than a month ago. They are fully approved. I just hadn’t tested the game on actual Roblox until now. I swapped it out with other ids and they also didnt show up.

Try printing the mouse.its possible that the mouse isnt detected. If it does then make sure that your string for asset id is correct(which is very less likely).

palm tree ninjago big boy I see your issue

local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id=IDGOESHERE"
2 Likes