Getting Local script to find things in Module script

I have a Gui that pops up when your mouse hovers over an object and a description box that changes depending on the item. I’m trying to get my local script and module script to match names according to the mouse’s target and retrieve the description, but its not changing.

What I have right now isn’t working, Im not getting any errors

1 Like

Looks like on line 21 you’re comparing the mouse target’s name with the value that the corresponding name is pointing to. Try replacing line 21 with

right now essentially the question is: "does target.Name = {["Description] = “…”}

instead just try seeing if the name exist in your table:

if objectdescription[mouse.Target.name] then 
1 Like

That looks like its focusing more on what the mouse is pointing on than what I’m trying to achieve. It seems that solution/link is more focused on the mouse hovering over a GUI, while I’m just looking for a way to get the text property in a working billboard GUI to change.

Hasn’t seemed to change much, still no errors. I’ve tried with keeping the currently grayed-out line as well as trying it without

sorry try if objectdescription[mouse.Taraget.Name] then

I am sorry, seems like I didn’t read your topic correctly :no_mouth:

1 Like

Well, with the lines grayed out I’m getting an error


image
Using those lines removes the error but still doesn’t change the text

Tried reversing the order, no errors but no changes

update line 23 to be ObjectDesc.Text = objectdescription[mouse.Target.Name].Description too

Tracebacks are your best friend! They can be a little hard to read, but they tell you whats wrong with your code. Use them to your advantage. Figure out why are we indexing nil? Its because objectdescription[name] doesn’t exists. Adjust your code accordingly :slight_smile:

Im getting a bit thrown off so lets start from after the ObjectName.Text

if objectdescription[mouse.Target.Name] then
			if mouse.Target.Name == objectdescription[name] then
				ObjectDesc.Text = objectdescription[mouse.Target.Name].Description
				end
			end
		end

Is this what it should be?

what you’re looking for should be something like this

UIS.InputChanged:Connect(function(input: InputObject, proc: boolean) --The first argument in InputChanged is the input that changed
	if mouse.Target and mouse.Target:FindFirstChild("EasterEgg") then
		local info = objectdescription[mouse.Target.Name] -- Does the targeted item exist in our table?
		if info then 
			ObjectInfoGui.Enabled = true
			ObjectInfoGui.Adornee = mouse.Target.Name
			ObjectName.Text = mouse.Target.Name
			ObjectDesc.Text = info.Description -- Set the text to the coresponding description 
		end
	end
end)

Well, putting it in the way it is it wont function because the adornee is set to the name, however removing the name I just get the same results as I always do

Im wondering if something is wrong with ObjectName and ObjectDesc neither are changing their text, and they woudnt function as variables when put them under ObjectInfoGui or DescriptionBox which are their respective parents who have working variables. I had to write out the whole game.workspace.startgui…

LOL! It was! Its working now!
Thanks so much for your help and reworking things with me!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.