Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Why cant i see the beam of the gun when i shoot?

Asked by 5 years ago
Edited 5 years ago

I made a gun that shoots. It works, but it doesnt show the beam/bullet. Can someone help me? thanks!

script:

local isincar = false
local mouse = game.Players.LocalPlayer:GetMouse()
local player = game.Players.LocalPlayer

mouse.Button1Down:Connect(function()
    local h = script.Parent:WaitForChild("cAr").Value.Parent.Parent.Body.lala
    local ray = Ray.new(h.CFrame.p, (mouse.Hit.p - h.CFrame.p).unit * 300)
        local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
        local b = Instance.new("Part")
        b.BrickColor = BrickColor.new("Bright yellow")
b.FormFactor = "Custom"
b.Material = "Plastic"
b.Transparency = 0
b.Anchored = true
b.Locked = true
b.CanCollide = false
local distance = (h.CFrame.p - position).magnitude
b.Size = Vector3.new(0.3, 0.3, distance)
b.CFrame = CFrame.new(h.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(b, 0.1)

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(30)
            end
        end
end)
0
FormFactor is deprecated. So is CFrame.p. Use CFrame.Position User#19524 175 — 5y
0
didnt work. ieatandisbaconhair 77 — 5y
0
In between lines 19 and 20 set the parent to workspace lol User#19524 175 — 5y
0
umg thx!!!!111!!!!111!! ieatandisbaconhair 77 — 5y

Answer this question