Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 3 years ago

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.

0
maybe make ItemName:Clone() a varible so. local item = ItemName:Clone() item.Parent = p.Backpack imagoodlolboyeee 30 — 4y
0
Didn't work imagoodlolboyeee, got this error: Backpack is not a valid member of MeshPart "Workspace.Anotherperson_999.Scrap.Handle"  AnotherPerson_999 28 — 4y
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. Soban06 410 — 4y
0
And how do I do that? AnotherPerson_999 28 — 4y

1 answer

Log in to vote
0
Answered by 3 years ago

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)
Ad

Answer this question