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

So I'm trying making an on monster kill put on inventory script?

Asked by 6 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

I tried putting this script in the monster local Humanoid = script.Parent.Human function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local theinventory = tag.Value:findFirstChild("PlayerGui").Inventory2 local theinventoryparts = theinventory:GetChildren() for i, v in pairs(theinventoryparts) do wait(0.5) if v.SlotValue.Value == "" then v.SlotValue.Value = "Wood" --Change this to desired variable so you can have any weapon v.Ammt.Value = 5 v.SlotLabel.Text = v.Ammt.Value v.SlotImage.Image = "http://www.roblox.com/asset/?id=539465370" break elseif v.SlotValue.Value == "Wood" then v.Ammt.Value = v.Ammt.Value + 5 v.SlotLabel.Text = v.Ammt.Value break --This script we just wrote will make it so you can stack wood end end wait(0.1) script:remove() end end end Humanoid.Died:connect(PwntX_X) but it doesn't seem to work

0
Put the script into a code block please Rinextel 291 — 6y

1 answer

Log in to vote
0
Answered by
Bisoph 5
6 years ago
local Humanoid = script.Parent.Human
function PwntX_X() 
    local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
            local theinventory = tag.Value:findFirstChild("PlayerGui").Inventory2
            local theinventoryparts = theinventory:GetChildren() 
            for i, v in pairs(theinventoryparts) do 
                wait(0.5) 
                if v.SlotValue.Value == "" then 
                    v.SlotValue.Value = "Wood" --Change this to desired variable so you can have any weapon 
                    v.Ammt.Value = 5 
                    v.SlotLabel.Text = v.Ammt.Value 
                    v.SlotImage.Image = "http://www.roblox.com/asset/?id=539465370" 
                    break 
                elseif 
                    v.SlotValue.Value == "Wood" then 
                        v.Ammt.Value = v.Ammt.Value + 5
                        v.SlotLabel.Text = v.Ammt.Value 
                        break --This script we just wrote will make it so you can stack wood 
                    end 
                end 
            wait(0.1) 
            script:remove() 
        end 
    end 
end 

Humanoid.Died:connect(PwntX_X)

You should also give the output so that it is easier to help you.

One thing I speculate is that it doesn't work because there is no child in the character (or it may not actually be a character) named "Human".

Also, I think maybe it does not work because the tag doesn't exist when you kill the monster.

Ad

Answer this question