-- Lekce 11 – Klávesy a myš
-- LocalScript ve StarterPlayer > StarterPlayerScripts

vstup = game:GetService("UserInputService")
mys = game.Players.LocalPlayer:GetMouse()

vstup.InputBegan:Connect(function(input, piseVChatu)
    if piseVChatu then
        return                                   -- hráč píše do chatu
    end

    -- 11.1 Kouzelné klávesy K a L
    if input.KeyCode == Enum.KeyCode.K then
        workspace.Koule.Transparency = 1
        workspace.Koule.CanCollide = false
    end
    if input.KeyCode == Enum.KeyCode.L then
        workspace.Koule.Transparency = 0
        workspace.Koule.CanCollide = true
    end

    -- 11.2 Levé tlačítko myši: Kostka bude z cihel
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        workspace.Kostka.Material = Enum.Material.Brick
    end

    -- 11.3 Prostřední tlačítko myši: díl pod myší bude láva
    if input.UserInputType == Enum.UserInputType.MouseButton3 then
        dil = mys.Target
        if dil and dil.Name ~= "Baseplate" then
            dil.Material = Enum.Material.CrackedLava
        end
    end

    -- 11.4 Barvy na klávesách R, G, B
    if input.KeyCode == Enum.KeyCode.R then
        workspace.Kostka.Color = Color3.new(1, 0, 0)
    elseif input.KeyCode == Enum.KeyCode.G then
        workspace.Kostka.Color = Color3.new(0, 1, 0)
    elseif input.KeyCode == Enum.KeyCode.B then
        workspace.Kostka.Color = Color3.new(0, 0, 1)
    end
end)
