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

[CLOSED] I am trying to make a refinery machine, but my script isn't working. Why is that so?

So far what I have done is taken a script from a shop button and the script from a keycard door to try and make a brick that, when touched with a tool removes the tool that touched it and then gives you something else. It doesn't work though, this is what I have:

script.Parent.Touched:connect(function(p)
	if p.Parent.Name == "Scrap" then 
		local ItemName = game.Lighting.Box
		ItemName:Clone().Parent = p.Backpack
	end
end)

I don't know how to make the removing tool either. Any help is appreciated.

4 comments

0

maybe make ItemName:Clone() a varible so. local item = ItemName:Clone() item.Parent = p.Backpack

0

Didn't work imagoodlolboyeee, got this error: Backpack is not a valid member of MeshPart "Workspace.Anotherperson_999.Scrap.Handle" 

0

You are trying to check if the thing that touched if it's name is "Scrap". That part is fine, but when you are saying that 'p.Parent', p is basically "Scrap" (if that is the thing that touched it). Scrap does not have 'Backpack'. Because it is an item. You need to get the player who had that item. Then get that player's backpack.

0

And how do I do that?

1 answer

Thank you soban06. I figured out how to do it.

script.Parent.Touched:connect(function(p)
	if p.Parent.Name == "Scrap" then 
		local ItemName = game.Lighting.Box
		ItemName:Clone().Parent = p.Parent.Parent
		p.Parent:Destroy()
	end
end)

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