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

Pointer brick disappearing when mouse isn't moving?

I am making a pointer script where a pointer follows the mouse. However the pointer should only be visible to a player when the mouse is pointing to the baseplate.

Script

local player=game.Players.LocalPlayer
local mouse=player:GetMouse()
local pointer=Instance.new("Part",(game.Workspace))

pointer.Name=("pointer")
pointer.Shape=("Ball")
pointer.BrickColor=BrickColor.new("Really red")
pointer.Size=Vector3.new(0.5,0.5,0.5)
pointer.TopSurface=("Smooth")
pointer.BottomSurface=("Smooth")
pointer.Anchored=true
pointer.Transparency=0
mouse.Move:connect(function()
	if mouse.Target then
		if mouse.Target.Name=="BasePlate" then
			local cframe=mouse.Hit
			pointer.CFrame=(cframe)
			pointer.Transparency=0
		else
			pointer.Transparency=1
		end
	end
end)

My problem here is that the pointer disappears not only when the target is not baseplate but also when the mouse stops moving. when the mouse moves on top of baseplate is the only time that it is visible. Someone please tell me how to do what i want to do?

1 answer

✓ Accepted answer

Ok, I'm going to assume you want a ball to follow the mouse when it's pointing at a specific part.

The mouse will hit the ball, and then mouse.Target will be the ball. So you would need the parent to be player.Character. If it's player.Character, the mouse will ignore it.

local player=game.Players.LocalPlayer
local mouse=player:GetMouse()
local pointer=Instance.new("Part",(player.Character))

pointer.Name=("pointer")
pointer.Shape=("Ball")
pointer.BrickColor=BrickColor.new("Really red")
pointer.Size=Vector3.new(0.5,0.5,0.5)
pointer.TopSurface=("Smooth")
pointer.BottomSurface=("Smooth")
pointer.Anchored=true
pointer.Transparency=0
mouse.Move:connect(function()
    if mouse.Target then
        if mouse.Target.Name=="BasePlate" then
            local cframe=mouse.Hit
            pointer.CFrame=(cframe)
            pointer.Transparency=0
        else
            pointer.Transparency=1
        end
    end
end)

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