Hi. I am trying to make it so that when a player hovers over an ore while the tool is equipped, then it will change the gui's text to whatever ore it was. The ore is a model, hence the Parent.Name.
local tool = script.Parent
local handle = tool.Handle
local equipped = false
local player = game.Players.LocalPlayer
local cursor = player:GetMouse()
local cursorPos = cursor.Target
local ore = {"BaseOreRock", "CopperOre", "IronOre", "SilverOre", "GoldOre", "EmeraldOre", "RubyOre", "SapphireOre", "DiamondOre", "PlatinumOre"}
local gui = player:WaitForChild("PlayerGui"):WaitForChild("OreGui").TextLabel
tool.Equipped:Connect(function()
cursor.Move:Connect(function(mouse)
cursorPos = cursor.Target
pcall(function()
local cursorObject = cursorPos
if cursorObject.Parent.Name == ore then
gui.Text = cursorObject.Name
else
gui.Text = "None"
end
end)
end)
end)

10 comments
You beat me to it :(
I feel you:) I've worked with Fierce before, I had a quick answer to it, since I've been writing something very similar
Hiya. Thanks for the help! However, when I went and tested it out, it only worked for the last item in the table (PlatinumOre). The crazy thing is, when I do 'print(cursorObject.Parent.Name)' instead of gui.Text, it works perfectly fine. Hmm.
Let me take a look
This could be an issue with spelling? Check if they're exact
Just saw that it was 'ipairs' instead of 'pairs'. Changed that, but still had the same issue
I just posted what I had so far to the answers. Have a look
Nevermind, I found out the problem. Once I got rid of gui.Text = "None", the problem disappeared.. it was so weird. But I thank you for the help!
Hm, that's interesting, I've been having absurd issues like that too, If I make something nil, it freezes my mouse;)
Glad to help