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

Mouse.Target is only showing one part?

I'm trying to make a survival game, right now I am working on the gui where it shows the text of what the item is and gives a message about the item,

But It only works on one item, and not the others. please help?

local checkpart = function()
	for items,v in pairs(itemmodule) do
		if mouse.Target == itemmodule[items].directory then 
			changetext(ptb,itemmodule[items].name.. " [E]")
			changetext(tmessage,itemmodule[items].message)
			ptb.Visible = true;
			tmessage.Visible = true;
		elseif mouse.Target == nil or mouse.Target == game.Workspace.Baseplate then
			ptb.Visible = false;
			tmessage.Visible = false;
			
		end
	end
end

this is the module for the items

folderitem = game.Workspace:WaitForChild("folderitem");
local data = {
		flashlight = {
		directory = folderitem:WaitForChild("flashlight");
		name = "FLASHLIGHT";
		message = "CAN BE USED IN DARK PLACES";
	},
return data

1 answer

The reason

The reason you only see one item, is because there is only one item in your table. Come on, you should've seen that.

More important

You don't close your data table in the module script correctly. You forgot a } and there's a comma. Im suprised you didn't see that.

Check your Output for errors next time ;p

4 comments

0

Everything works properly. But Only shows one part instead of the rest in workspace, instead of telling me that its only one object, how about you tell him how to fix it?

0

Also that module script is not complete, the real one with all the items have atleast 300 lines of code, and has a proper closing.

0

I'm saying if I have two items in workspace named flashlight it would only display one of them

0

Then next time be more specific in your question.

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