local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:Connect(function(Key) Key = Key:lower() if Key == 'e' then Part = Instance.new('Part', game.Workspace) Part.Size = Vector3.new(2, 12,3) Part.Material = ("Ice") Part.CanCollide = false Part.Anchored = true Part.CFrame = Player.Character.Head.CFrame * CFrame.new(0,-2,-2) wait(1) Part:Destroy() end end) local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:Connect(function(Key) Key = Key:lower() if Key == 'e' then wait(0.1) Part = Instance.new('Part', game.Workspace) Part.Size = Vector3.new(2, 12,3) Part.Material = ("Ice") Part.CanCollide = false Part.Anchored = true Part.CFrame = Player.Character.Head.CFrame * CFrame.new(0,-2,-5) wait(1) Part:Destroy() end end) local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:Connect(function(Key) Key = Key:lower() if Key == 'e' then wait(0.2) Part = Instance.new('Part', game.Workspace) Part.Size = Vector3.new(2, 12,3) Part.Material = ("Ice") Part.CanCollide = false Part.Anchored = true Part.CFrame = Player.Character.Head.CFrame * CFrame.new(0,-2,-8) wait(1) Part:Destroy() end end) local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:Connect(function(Key) Key = Key:lower() if Key == 'e' then wait(0.3) Part = Instance.new('Part', game.Workspace) Part.Size = Vector3.new(2, 12,3) Part.Material = ("Ice") Part.CanCollide = false Part.Anchored = true Part.CFrame = Player.Character.Head.CFrame * CFrame.new(0,-2,-11) wait(1) Part:Destroy() end end) local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:Connect(function(Key) Key = Key:lower() if Key == 'e' then wait(0.4) Part = Instance.new('Part', game.Workspace) Part.Size = Vector3.new(2, 12,3) Part.Material = ("Ice") Part.CanCollide = false Part.Anchored = true Part.CFrame = Player.Character.Head.CFrame * CFrame.new(0,-2,-15) wait(1) Part:Destroy() end end)
First of all, KeyDown is deprecated. It works in Studio but not in the actual game. Second, you wasted a lot of time making the same variables over and over. Same with all the extra functions.
Instead of using KeyDown, use the UserInputService. Also, don't make the same variables and functions over and over.
A shortened example of what you're doing:
local player = game.Players.LocalPlayer local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, gpe) if not gpe and input.KeyCode == Enum.Q then part = Instance.new("Part", game.Workspace) part.Anchored = true part.CFrame = player.Character.Head.CFrame * CFrame.new(0, -2, -15) wait(1) part:Destroy() wait() partA = Instance.new("Part", game.Workspace) partA.Anchored = true partA.CFrame = player.Character.Head.CFrame * CFrame.new(0, -2, -15) wait(1) partA:Destroy() end end)
These are a couple mistakes. The answer to your question is lag...... I think. Also, even if Keydown wasn't deprecated, its pointless to do the "Key = Key:lower()" part. Hope this helps