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

How do I make a weld from a tool?

Asked by 7 years ago

Well, I made a gun in ROBLOX. Multiple in fact. And I want to make it weld your arms to make it look more realistic, welding works. Just the unwelding. To unweld the gun I used Weld:Destroy()

The only problem now is that your arms fall off of your body. Also, this weld is just some quick one I made, not one which had time put into, what I'm asking is can someone help me fix this?

Ammo = 5

damage = 50

AbleToFire2 = true

AbleToFire = true

enabled = true

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()

script.Parent.Equipped:connect(function(eventMouse)
    Player:WaitForChild("PlayerGui").ScreenGui4.Frame.Visible = true
eventMouse.Icon = "rbxasset://textures\\GunCursor.png"

        local RightArm = Player.Character:WaitForChild("Right Arm")
    local Torso = Player.Character:WaitForChild("Torso")
    local Weld = Instance.new("Weld")

    Weld.Part0 = Torso
    Weld.Parent = Torso 
    Weld.Part1 = RightArm
    Weld.C1 = CFrame.new(0, 0.5, 0.5) * CFrame.Angles(math.rad(-90), 0, math.rad(60))
end)

script.Parent.Unequipped:connect(function()
    Player:WaitForChild("PlayerGui").ScreenGui4.Frame.Visible = false
    local Weld = Player.Character.Torso:WaitForChild("Weld")    
    Weld:Destroy()
end)

script.Parent.Activated:connect(function()
    if Ammo > 0 and AbleToFire == true then
if AbleToFire2 == true then
    AbleToFire2 = false
Bullet = Instance.new("Part", workspace)
game.Debris:AddItem(Bullet, 10)
Bullet.CFrame = Player.Character["Right Arm"].CFrame * CFrame.new(-8, 0, -9.5)
Bullet.CFrame = CFrame.new(Bullet.Position, mouse.Hit.p)
Bullet.Size = Vector3.new(1, 1, 1)
Bullet.BrickColor = BrickColor.new("Really black")
Bullet.Shape = "Ball"
Bullet.Transparency = 1
Bullet.Name = "BarretBullet"
Bullet.Touched:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
    local Player2 = game.Players:GetPlayerFromCharacter(hit.Parent)
    if Player2.TeamColor == Player.TeamColor then

            else
    hit.Parent.Humanoid:TakeDamage(damage)
if enabled == false then
    enabled = true  
    enabled = false
    wait(0.1)
    enabled = true
wait(1)
Bullet:Destroy()
end
    end
end
end)

local Vel = Instance.new("BodyVelocity", Bullet)
Vel.Velocity = Bullet.CFrame.lookVector *100
Vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
script.Parent.GripPos = Vector3.new(0, -0.4, -1.8)
wait(0)
script.Parent.GripPos = Vector3.new(0, -0.4, -1.9)
script.Parent.FireSound:Play()
Ammo = Ammo - 1
Player.PlayerGui.ScreenGui4.Ammo.Value = Player.PlayerGui.ScreenGui4.Ammo.Value - 1
AbleToFire2 = false
wait(2.5)
AbleToFire2 = true
wait(.2)
Bullet.CanCollide = true
end
end
end)


mouse.KeyDown:connect(function(Key)
    if Key == "r" then  
if Ammo <= 4 then
if AbleToFire == true then
    AbleToFire = false
AbleToFire = false
    local Animation = script.Parent.Reload
    local AnimationPlay = Player.Character.Humanoid:LoadAnimation(Animation)
    AnimationPlay:Play()
script.Parent.ReloadSound:Play()
wait(2.5)
        Ammo = 5
            Player.PlayerGui.ScreenGui4.Ammo.Value = 5
            AbleToFire = true
end
end
end
end)

Remember the arms drop off of your body, after you unequip the gun.

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Store your welds in nil, then retrieve them again when you destroy the new ones.

OR better yet just manipulate the welds that are already in the character?

Sorry about the no code example.. your script was 100+ lines.

0
I tried that already, it appears the arms still drop off for me. And if you're talking about retrieving I think you mean create new ones after it's equipped again. Am I correct? Kraken_54 22 — 7y
0
No I mean parent it back into the torso. Goulstem 8144 — 7y
0
But honestly you should edit the welds that are already there. There's no possibility of the arms falling off then Goulstem 8144 — 7y
0
How would I retrieve it from nil?. Kraken_54 22 — 7y
View all comments (2 more)
0
Reference it with a variable. Then [variable].Parent = workspace. BUT AGAIN YOU SHOULD REALLY JUST EDIT THE WELDS THAT ARE ALREADY THERE OK Goulstem 8144 — 7y
0
Thanks! It worked!!! I'll accept your answer! Kraken_54 22 — 7y
Ad

Answer this question