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

Object not changing parents in my inventory script, help? [SOLVED]

Asked by 7 years ago
Edited 7 years ago

So I'm trying to make an inventory (something temporarily because I'm new to scripting), I'm trying to get the object to change its parent when the thing is true in my script :L Don't know if that made sense...

Here's the script

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Item = game.Workspace.Item
local slot = Player.PlayerGui.Inventory.Frame
local Slots = {}

mouse.Button1Down:connect(function()
   if mouse.Target:FindFirstChild("Pick up") then
      if slot.Slots.S1 == true then
        slot.Slots.S1.Value = false
        Item.Parent = slot
        local M1 = Instance.new("ImageButton", slot)
        M1.name = "Stol 1"
        table.insert(Slots, 1, 1)
        print(Slots[1])
elseif slot.Slots.S2 == true then   
        slot.Slots.S2.Value = false
        Item.Parent = slot
        local M1 = Instance.new("ImageButton", slot)
        M1.name = "Stol 2"
        table.insert(Slots, 2, 2)
        print(Slots[2])
elseif slot.Slots.S3 == true then   
        slot.Slots.S3.Value = false
        Item.Parent = slot
        local M1 = Instance.new("ImageButton", slot)
        M1.name = "Stol 3"
        table.insert(Slots, 2, 2)
        print(Slots[3])
elseif slot.Slots.S3 == true then   
        slot.Slots.S3.Value = false
        Item.Parent = slot
        local M1 = Instance.new("ImageButton", slot)
        M1.name = "Stol 3"
        table.insert(Slots, 2, 2)
        print(Slots[4])
    end
   end
end)

1
One thing that I see is that you may want to change your 'slot.Slots.S1 == true' to 'slot.Slots.S1.Value == true'. Although, I don't think this is your mane problem. Bluemonkey132 194 — 7y
0
:0 I'll try that when I get back on, thanks for your comment. Cyprus_Alexander 10 — 7y
0
It worked, thanks! Cyprus_Alexander 10 — 7y
0
Nicee Goulstem 8144 — 7y

Answer this question