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

Welding bullet to barrel for gun and it's not working.Help?

Asked by 5 years ago
Edited 5 years ago

i am trying to make a gun by adding a part to the barrel then destroying it shortly after just to do damage

--LOCAL SCRIPT


--common defenitions

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local equipAnim = script.Parent:WaitForChild("Equip"):WaitForChild("Equiping")
local tool = script.Parent
--events
local Shooting = script.Parent:WaitForChild("Shoot")
local Reloading = script.Parent:WaitForChild("Reload")
--on activation

Shooting.OnServerEvent:Connect(function()
    local bullet = Instance.new("Part",game.Workspace)
    bullet.Transparency = 0
    bullet.CanCollide = false
    bullet.Material = "SmoothPlastic"
    bullet.BrickColor = BrickColor.new("Curry")
    bullet.Name = player.Name.."'s Bullet"
    local weld = Instance.new("Weld")
    weld.Part0 = script.Parent.Barrel
    weld.Part1 = bullet
    weld.Parent = script.Parent.Barrel
    bullet.Anchored = false
    wait(0.1)
bullet:Destroy()
end)

1 answer

Log in to vote
0
Answered by 5 years ago

this should weld the bullet to the barrel for 0.1 seconds then the bullet will be destroyed.

--LOCAL SCRIPT


--common defenitions

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local equipAnim = script.Parent:WaitForChild("Equip"):WaitForChild("Equiping")
local tool = script.Parent
--events
local Shooting = script.Parent:WaitForChild("Shoot")
local Reloading = script.Parent:WaitForChild("Reload")
--on activation

Shooting.OnServerEvent:Connect(function()
    local bullet = Instance.new("Part",game.Workspace)
    bullet.Transparency = 0
    bullet.CanCollide = false
    bullet.Material = "SmoothPlastic"
    bullet.BrickColor = BrickColor.new("Curry")
    bullet.Name = player.Name.."'s Bullet"
    local weld = Instance.new("Weld")
    weld.Part0 = script.Parent.Barrel
    weld.Part1 = bullet
    weld.C0 = script.Parent.Barrel
    weld.C1 = bullet
    weld.Parent = script.Parent.Barrel
    bullet.Anchored = false
    wait(0.1)
bullet:Destroy()
end)
Ad

Answer this question