Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can someone help me fix the mouse hovering?

Asked by 5 years ago

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

Log in to vote
0
Answered by
vissequ 105
5 years ago
Edited 5 years ago
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)
0
how would i make it get the player? magentacrasyguy -7 — 5y
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 vissequ 105 — 5y
0
its not working magentacrasyguy -7 — 5y
0
how do i make it check to where its hovering above a certain object? magentacrasyguy -7 — 5y
View all comments (6 more)
0
it works for me on my end. Are you putting it in a localscript inside a tool? vissequ 105 — 5y
0
no i used serverscript magentacrasyguy -7 — 5y
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? magentacrasyguy -7 — 5y
0
What are you trying to do vissequ 105 — 5y
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 magentacrasyguy -7 — 5y
0
Do you use discord? I can explain this easier there vissequ 105 — 5y
Ad

Answer this question