So, i made a laser blaster and its kinds unbalanced because it doesnt has cooldown. so, i asked other people how and they said no, i tryed it myself but it failed. can you help me? the code:~~~~~~~~~~~~~~~~~ local tool = script.Parent local sound = tool:WaitForChild("Gunfire") local player = game:GetService("Players").LocalPlayer
tool.Equipped:connect(function(mouse) print("Tool equipped!")
if script.Parent.Canshoot then
mouse.Button1Down:connect(function()
print("Mouse pressed!")
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
script.Parent.Shooting.Value = true
local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("Really red")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.5
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
local distance = (tool.Gun.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(tool.Gun.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 0.1)
if script.Parent.Shooting.value then
script.Parent.Gunfire:Play()
script.Parent.Gun.PointLight.Enabled=true
wait(0.1)
script.Parent.Gun.PointLight.Enabled=false
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(22)
end
end
end
end)
end)

5 comments
Fixed
Hi, i did it but at the end) it says : expected identifier, got )
this is the code, again
its thge other ansewer VVVV
i missed some script thats why