Hi everyone, I’m new on the forum and I have a question about my game.
I want to make a spread for my weapon, but I don’t know how.
(give me please script and explain the some lines so that I can learn more)
LOCAL SCRIPT:
local tool = script.Parent
local handle = tool.Handle
local rate = tool:WaitForChild("Configure").Rate
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
tool.Activated:Connect(function()
local mouseHit = mouse.Hit.Position
tool.ShotEvent:FireServer(mouseHit,rate)
local bullet = game.ReplicatedStorage.Bullet:Clone()
bullet.Parent = workspace
bullet.CFrame = CFrame.new(handle.Position, mouseHit)
local Velocity = Instance.new("BodyVelocity", bullet)
Velocity.Velocity = bullet.CFrame.LookVector * 800
game:GetService("Debris"):AddItem(bullet, 15)
end)
SERVER SCRIPT:
local tool = script.Parent
local handle = tool.Handle
tool.ShotEvent.OnServerEvent:Connect(function(player, mouseHit, rate)
local shot = handle.FireSound:Clone()
shot.Parent = handle
shot:Play()
game:GetService("Debris"):AddItem(shot,4)
end)