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)

4 comments

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.

0

:0 I'll try that when I get back on, thanks for your comment.

0

It worked, thanks!

0

Nicee