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

can someone help me fix the mouse hovering?

i don't know how to make it check if the players mouse is hovering over something

local TotalToDrop = math.random(1, 10)

local OreMineTest = game.Workspace.OreMineTest

function onActivation(player)

print("Tool activated")

player:GetMouse()

if player.Mouse == OreMineTest then

local Ore = game.ReplicatedStorage.Items.TestOre:Clone()

Ore.Parent = game.Workspace.Bases:WaitForChild(player.Name)

Ore.Part.Position = player.Character.HumanoidRootPart.Position - Vector3.new(0,0,5)

end

end

1 answer

local tool = script.Parent

  

tool.Enabled = true

tool.Equipped:connect(function(mouse)

  

mouse.Move:Connect(function()

	if mouse.Target then

		print("Mouse target: "..(tostring(mouse.Target)))

		local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid") or mouse.Target.Parent.Parent:FindFirstChild("Humanoid")

			if humanoid then

				if game:GetService("Players"):FindFirstChild(humanoid.Parent.Name) then

				print("A player has been found")

				end

			end

		end

	end)

end)

10 comments

0

how would i make it get the player?

0

I've updated it to to show that. Please see above. You would see if there is a humanoid in the parent of the target and then see if that humanoid is a player, the way i did it is by seeing if the name of parent of the humanoid exists as a player

0

its not working

0

how do i make it check to where its hovering above a certain object?

0

it works for me on my end. Are you putting it in a localscript inside a tool?

0

no i used serverscript

0

its working but how would i use local Ore = game.ReplicatedStorage.Items.TestOre:Clone() Ore.Parent = game.Workspace.Bases:WaitForChild(humanoid.Parent.Name) Ore.Part.Position = humanoid.Parent.Character.Torso.Position - Vector3.new(0,0,5) in it?

0

What are you trying to do

0

they click a part with their tool in their hand and i want it to take anywhere from 1-10 clicks to make it spawn the part - basically digging up an ore

0

Do you use discord? I can explain this easier there

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