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

Welded part doesn't remain stationary when activating tool?

Asked by 6 years ago
Edited 6 years ago

GIF Below

https://gyazo.com/0103bb632750c5cc74788da1f22148f7

The blue sphere should remain stationary, It's welded to the arm.

Picture of hierarchy Below

https://gyazo.com/7e4fc91a5b20255544566c27551203b1

local player = game.Players.LocalPlayer
char = player.Character
hum = char:WaitForChild("Humanoid")
tool = script.Parent
zarm = tool.ZArm
rhand = char:WaitForChild("RightHand")
zarm.Anchored = false
userinput = game:GetService("UserInputService")
cooldown = 0
beam = tool.BeamAttack
pemitter = beam.ParticleEmitter
keyheld = false

tool.Equipped:connect(function()
    local anim1 = hum:LoadAnimation(tool.ArmPosition)
    anim1:Play()
    zarm.CFrame = rhand.CFrame * CFrame.new(-0.25,-0.75,-1)
    zarm.CFrame = zarm.CFrame * CFrame.Angles(0,0,-1.75)
    local weld = Instance.new("Weld")
    weld.Parent = tool
    weld.Part0 = zarm
    weld.C0 = zarm.CFrame:inverse()
    weld.Part1 = rhand
    weld.C1 = rhand.CFrame:inverse()
    tool.BeamAttack.CFrame = zarm.CFrame * CFrame.new(1.8,0,-2.3)
    local weld1 = Instance.new("Weld")
    weld1.Parent = tool
    weld1.Part0 = tool.BeamAttack
    weld1.C0 = tool.BeamAttack.CFrame:inverse()
    weld1.Part1 = zarm
    weld1.C1 = zarm.CFrame:inverse()
end)

function onKeyPress(inputObject,gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.Q then
        keyheld = true
        while keyheld do
            beam.Transparency = 0
            pemitter.Transparency = NumberSequence.new(0)
            beam.Size = beam.Size + Vector3.new(0.1,0.1,0.1) 
            wait()
        end
    end
end

function onKeyRelease(inputObject,gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.V then
        keyheld = false
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
0
Try parenting after you edit the the Weld properties. There could also be a problem with editing the Weld's C1 property, I usually leave it untouched. PreciseLogic 271 — 6y

Answer this question