ADVERTISEMENTREMOVE ADS
M4A1-FE-TOOL
46,780 views
Script Preview
Description
ADVERTISEMENTREMOVE ADS
98 Lines • 2.72 KiB
-- FE M4A1 с моделью (LocalScript)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Создаём Tool
local tool = Instance.new("Tool")
tool.Name = "FE M4A1"
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Parent = player:WaitForChild("Backpack")
-- Клонируем модель из ReplicatedStorage
local gunModelTemplate = ReplicatedStorage:WaitForChild("M4A1Model")
local gunModel = gunModelTemplate:Clone()
gunModel.Parent = workspace
gunModel.Anchored = false
gunModel.CanCollide = false
-- Weld (чтобы оружие держалось в руке)
local weld = Instance.new("Weld")
weld.Part0 = gunModel:FindFirstChildWhichIsA("BasePart")
weld.Part1 = nil
weld.Parent = gunModel
-- Эффект выстрела
local function muzzleFlash(pos)
local p = Instance.new("Part")
p.Anchored = true
p.CanCollide = false
p.Shape = Enum.PartType.Ball
p.Size = Vector3.new(0.3,0.3,0.3)
p.Material = Enum.Material.Neon
p.Color = Color3.fromRGB(255, 200, 100)
p.CFrame = CFrame.new(pos)
p.Parent = workspace
Debris:AddItem(p, 0.1)
end
-- Трассер пули
local function bulletTracer(fromPos, toPos)
local beam = Instance.new("Part")
beam.Anchored = true
beam.CanCollide = false
beam.Size = Vector3.new(0.1, 0.1, (fromPos - toPos).Magnitude)
beam.Color = Color3.fromRGB(255, 255, 0)
beam.Material = Enum.Material.Neon
beam.CFrame = CFrame.new(fromPos, toPos) * CFrame.new(0,0,-beam.Size.Z/2)
beam.Parent = workspace
Debris:AddItem(beam, 0.15)
end
-- Стрельба
local shooting = false
local function shootLoop()
while shooting do
local char = player.Character
if not char then break end
local head = char:FindFirstChild("Head")
if not head then break end
local origin = head.Position
local dir = (mouse.Hit.p - origin).Unit * 300
local result = origin + dir
muzzleFlash(origin)
bulletTracer(origin, result)
task.wait(0.1) -- скорострельность
end
end
tool.Equipped:Connect(function()
local char = player.Character or player.CharacterAdded:Wait()
local hand = char:FindFirstChild("RightHand") or char:FindFirstChild("Right Arm")
if hand then
weld.Part1 = hand
gunModel.CFrame = hand.CFrame * CFrame.new(0,-0.5,-1)
end
end)
tool.Unequipped:Connect(function()
weld.Part1 = nil
end)
tool.Activated:Connect(function()
shooting = true
shootLoop()
end)
tool.Deactivated:Connect(function()
shooting = false
end)
print("FE M4A1 загружен (визуальная версия)")
ADVERTISEMENTREMOVE ADS
ADVERTISEMENTREMOVE ADS


Comments