The one error that appears is: bad argument #2 to '?'(UDim2 expected, got number)
the script is:
local mouse = game:GetService('Players').LocalPlayer:GetMouse()
local HotbarItems = {'Grass','Stone','Dirt','Sand','TorchWall','MoltenRock','Netherrack','Water','Lava'}
local ItemList = {'TorchWall','Fire','NetherPortal','Grass','Dirt','Stone','Bedrock','DiamondOre','CopperOre','IronOre','EmeraldOre','GoldOre','RedstoneOre','MoltenRock','Bricks','Leaves','WoolDarkGray','WoolOrange','WoolGray','WoolBrown','WoolDarkGreen','WoolLightGreen','WoolGreen','WoolBlue','WoolLightBlue','WoolLightYellow','SpruceWood','OakWood','DarkOakWood','AcaciaWood','AcaciaWoodPlanks','DarkOakWoodPlanks','OakWoodPlanks','SpruceWoodPlanks','Concrete','Cobblestone','Sand','Gravel','Netherrack','WoolRed','Water','Lava'}
local Selected = 1
game:GetService('Players').LocalPlayer.CharacterAdded:connect(function()
game:GetService('Players').LocalPlayer.Character:WaitForChild('Humanoid')
PunchAnim = game:GetService('Players').LocalPlayer.Character.Humanoid:LoadAnimation(script.Punch)
PlaceAnim = game:GetService('Players').LocalPlayer.Character.Humanoid:LoadAnimation(script.Place)
end)
function CreativeItemClick(Button)
Button.MouseButton1Click:connect(function()
HotbarItems[Selected] = Button.ItemTag.Value
end)
end
mouse.Button1Down:connect(function()
local target = mouse.Target
PunchAnim:Play()
for index, value in ipairs(ItemList) do
if target.Name == value then
target:Destroy()
end
end
end)
mouse.Button2Down:connect(function()
PlaceAnim:Play()
local PlacedObjectIdentifier = HotbarItems[Selected]
local ClonedBlock = game:GetService('Lighting'):FindFirstChild(PlacedObjectIdentifier):Clone()
ClonedBlock.Parent = game:GetService('Workspace')
local p=mouse.Hit.p
local x,y,z = p.x,p.y,p.z
-- Added stuff
xdif = math.floor(x/4+.5)*4 -- Grids positions X value (0,4,8,12,16 etc)
ydif = math.floor(y/4+.5)*4 -- Grids positions Y value (0,4,8,12,16 etc)
zdif = math.floor(z/4+.5)*4 -- Grids positions Z value (0,4,8,12,16 etc)
ClonedBlock.CFrame = CFrame.new(xdif,ydif,zdif)
end)
mouse.KeyDown:connect(function(key)
if key == '1' then
Selected = 1
script.Parent.Selecter:TweenPosition(UDim2.new(0,0,0,0))
elseif key == '2' then
Selected = 2
script.Parent.Selecter:TweenPosition(UDim2.new(0.1,0,0,0))
elseif key == '3' then
Selected = 3
script.Parent.Selecter:TweenPosition(UDim2.new(0.2,0,0,0))
elseif key == '4' then
Selected = 4
script.Parent.Selecter:TweenPosition(UDim2.new(0.3,0,0,0))
elseif key == '5' then
Selected = 5
script.Parent.Selecter:TweenPosition(UDim2.new(0.4,0,0,0))
elseif key == '6' then
Selected = 6
script.Parent.Selecter:TweenPosition(UDim2.new(0.5,0,0,0))
elseif key == '7' then
Selected = 7
script.Parent.Selecter:TweenPosition(UDim2.new(0.6,0,0,0))
elseif key == '8' then
Selected = 8
script.Parent.Selecter:TweenPosition(UDim2.new(0.7,0,0,0))
elseif key == '9' then
Selected = 9
script.Parent.Selecter:TweenPosition(UDim2.new(0.8,0,0,0))
end
end)
game:GetService('RunService').RenderStepped:connect(function()
wait(.1)
local Slot1V = string.sub(HotbarItems[1],1,2)
local LegitSlot1 = string.upper(Slot1V)
script.Parent.Slot1.Text = LegitSlot1
local Slot2V = string.sub(HotbarItems[2],1,2)
local LegitSlot2 = string.upper(Slot2V)
script.Parent.Slot2.Text = LegitSlot2
local Slot3V = string.sub(HotbarItems[3],1,2)
local LegitSlot3 = string.upper(Slot3V)
script.Parent.Slot3.Text = LegitSlot3
local Slot4V = string.sub(HotbarItems[4],1,2)
local LegitSlot4 = string.upper(Slot4V)
script.Parent.Slot4.Text = LegitSlot4
local Slot5V = string.sub(HotbarItems[5],1,2)
local LegitSlot5 = string.upper(Slot5V)
script.Parent.Slot5.Text = LegitSlot5
local Slot6V = string.sub(HotbarItems[6],1,2)
local LegitSlot6 = string.upper(Slot6V)
script.Parent.Slot6.Text = LegitSlot6
local Slot7V = string.sub(HotbarItems[7],1,2)
local LegitSlot7 = string.upper(Slot7V)
script.Parent.Slot7.Text = LegitSlot7
local Slot8V = string.sub(HotbarItems[8],1,2)
local LegitSlot8 = string.upper(Slot8V)
script.Parent.Slot8.Text = LegitSlot8
local Slot9V = string.sub(HotbarItems[9],1,2)
local LegitSlot9 = string.upper(Slot9V)
script.Parent.Slot9.Text = LegitSlot9
end)
-- the problem is from here and below
Row = 0
MaxSlotsPerRow = 10
Slot = 0
LastSlot = nil
script.Parent.Parent:WaitForChild('CreativeInventory')
for index, value in ipairs(ItemList) do
if Slot >= MaxSlotsPerRow then
Row = Row + 0.1
end
Slot = Slot + 1
local BlockName = string.sub(value,1,2)
local BlockTag = string.upper(BlockName)
BlockButton = game:GetService('Lighting').Item:Clone()
BlockButton.Parent = script.Parent.Parent.CreativeInventory.Blocks
if LastSlot == nil then
BlockButton.Position = UDim2.new(BlockButton.Position.X.Scale + .1, 0, Row, 0)
else
BlockButton.Position = UDim2.new(LastSlot.Position.X.Scale + .1, 0, Row, 0)
end
BlockButton.Text = BlockTag
BlockButton.ItemTag.Value = value
CreativeItemClick(BlockButton)
LastSlot = BlockButton
end

1 comment
this was already solved