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

Why Wont This Script Return The First Letter Of The Block Name? [SOLVED]

Asked by 7 years ago
Edited 7 years ago

Why wont this work? Here is the script:

local mouse = game:GetService('Players').LocalPlayer:GetMouse()
local HotbarItems = {'Grass','Stone','Bricks','Sand','WoolRed','MoltenRock','Netherrack','Water','Lava'}
local ItemList = {'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

mouse.Button1Down:connect(function()
    local target = mouse.Target
    for index, value in ipairs(ItemList) do
    if target.Name == value then
    target:Destroy()
end
end
end)

mouse.Button2Down:connect(function()
    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,1)
    local LegitSlot1 = string.upper(Slot1V)
    script.Parent.Slot1.Text = LegitSlot1
    local Slot2V string.sub(HotbarItems[2],1,1) -- this part of every slot wont work 
    local LegitSlot2 = string.upper(Slot2V) -- and this part too
    script.Parent.Slot2.Text = LegitSlot2
    local Slot3V string.sub(HotbarItems[3],1,1)
    local LegitSlot3 = string.upper(Slot3V)
    script.Parent.Slot3.Text = LegitSlot3
    local Slot4V string.sub(HotbarItems[4],1,1)
    local LegitSlot4 = string.upper(Slot4V)
    script.Parent.Slot4.Text = LegitSlot4
    local Slot5V string.sub(HotbarItems[5],1,1)
    local LegitSlot5 = string.upper(Slot5V)
    script.Parent.Slot5.Text = LegitSlot5
    local Slot6V string.sub(HotbarItems[6],1,1)
    local LegitSlot6 = string.upper(Slot6V)
    script.Parent.Slot6.Text = LegitSlot6
    local Slot7V string.sub(HotbarItems[7],1,1)
    local LegitSlot7 = string.upper(Slot7V)
    script.Parent.Slot7.Text = LegitSlot7
    local Slot8V string.sub(HotbarItems[8],1,1)
    local LegitSlot8 = string.upper(Slot8V)
    script.Parent.Slot8.Text = LegitSlot8
    local Slot9V string.sub(HotbarItems[9],1,1)
    local LegitSlot9 = string.upper(Slot9V)
    script.Parent.Slot9.Text = LegitSlot9
end)
0
You don't have any equals signs. "local Slot1V string.sub(HotbarItems[1],1,1)" 1waffle1 2908 — 7y

Answer this question