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

why does the gui not move to my mouse's position?

i have a script where when you position your mouse over any part that is lootable, it brings a textlabel to your mouse's position, and displays the name of the part. but for some reason it's not working. the script is located inside of a screengui. here is my script:

local plr = script.Parent.Parent.Parent
local Char = plr.Character
local label = script.Parent.TextLabel
local mouse = plr:GetMouse()
local Lootables = {"Small Stone", "Large Stone", "Gold"}

mouse.Move:connect(function()
	if mouse.Target.Name == Lootables then
	print(mouse.Target.Name)
	label.Text = mouse.Target.Name
	label.Position = UDim2.new(0,mouse.X,0,mouse.Y)
	end
end)

I think the problem is in line 8.

1 comment

0

nothing to do with this bit why is player defined as parent parent parent

1 answer

✓ Accepted answer

It's indeed in Line 8.

Currently you're just checking if the Name equals an entire table, which is never going to work, seeing that one is a string, and the other is a table.

you should do if mouse.Target and Lootables[mouse.Target.Name] then to check if the Target is in the loot table.

I also suggest changing your variable from Lootables to LootTables (double t)

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