Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont the ClickDetector icon show?

So when you hover over a gui the icon is supposed to show, but it seems to replace the Click icon with the regular mouse right away, and i cant figure out how to fix that

 player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
	if player.leaderstats.Timber.Value >= 50 then
		player.leaderstats.Timber.Value = player.leaderstats.Timber.Value - 50
		game.ReplicatedStorage.Pickaxe:Clone().Parent = player.Backpack
	end
end)

player = game.Players.LocalPlayer 
script.Parent.MouseButton1Click:connect(function() 
	if player.leaderstats.Timber.Value >= 50 then 
		player.leaderstats.Timber.Value = player.leaderstats.Timber.Value - 50 
		game.ReplicatedStorage.Pickaxe:Clone().Parent = player.Backpack 
	end 
end) 

local changing = false 
local mouse = game.Players.LocalPlayer:GetMouse() 
script.Parent.MouseEnter:connect(function(hovering)
	if hovering then  
	mouse.Icon = "rbxasset://textures/DragCursor.png" 
	else
		mouse.Icon = "rbxasset://textures/ArrowFarCursor.png"
	end
end)  

script.Parent.MouseLeave:connect(function(left) 
	if left then
	mouse.Icon = "rbxasset://textures/ArrowFarCursor.png"
	else
		mouse.Icon = "rbxasset://textures/DragCursor.png" 
		end
end)

1 answer

The MouseEnter and MouseLeave event always return the 2D position of the PlayerMouse, and not what, i suppose is, a confirmation that the mouse did. You need not worry about if the event is sure it fired itself, because it knows when it fires.

local player = game.Players.LocalPlayer --Instead of setting those repeatedly, just put them on top and make them local. Yes, it works.
local changing = false 
local mouse = game.Players.LocalPlayer:GetMouse() 

script.Parent.MouseButton1Click:connect(function()
    if player.leaderstats.Timber.Value >= 50 then
        player.leaderstats.Timber.Value = player.leaderstats.Timber.Value - 50
        game.ReplicatedStorage.Pickaxe:Clone().Parent = player.Backpack
    end
end)

script.Parent.MouseButton1Click:connect(function() 
    if player.leaderstats.Timber.Value >= 50 then 
        player.leaderstats.Timber.Value = player.leaderstats.Timber.Value - 50 
        game.ReplicatedStorage.Pickaxe:Clone().Parent = player.Backpack 
    end 
end) 


script.Parent.MouseEnter:connect(function() --As you'll probably not be using the x and y integers, i blanked this out
    mouse.Icon = "rbxasset://textures/DragCursor.png" 
end)  

script.Parent.MouseLeave:connect(function()
    mouse.Icon = "rbxasset://textures/ArrowFarCursor.png"
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.