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

how could i fix this bad argument CFrame error that shows up in the output?

Asked by 5 years ago
Edited 5 years ago

the output keeps on saying - bad argument #3 to 'C0' (CFrame expected, got nil) here is the script

01local rp = game.ReplicatedStorage
02local dark = rp:WaitForChild("Right Hand")
03 
04 
05game.Players.PlayerAdded:Connect(function(player)
06    player.CharacterAdded:connect(function(character)
07        character:WaitForChild("RightHand").Transparency = 0
08 
09        local ClonedRH = dark:Clone()
10        ClonedRH.Parent = character
11 
12        ClonedRH:SetPrimaryPartCFrame(character:WaitForChild("RightHand").CFrame)
13        local Weld = Instance.new("Weld")
14        Weld.Part0 = ClonedRH.Main
15        Weld.Part1 = character:WaitForChild("RightHand")
16        Weld.C0 = dark:SetPrimaryPartCFrame(CFrame.new(0,0,0) * CFrame.Angles(0,0,0))
17        Weld.Parent = character:WaitForChild("RightHand")
18    end)
19end)   

i did this script to weld a model to a characters right hand. but now im trying to rotate it the right way bc when i spawn its rotated differently. and when i would rotate it , it would only rotate the main part thats why i did setprimarypartcframe now its giving the error that i mentioned earlier. pay attention to line 16. and if you know how to fix it can you modify the script and elaborate.

can someone help me please? ty

2 answers

Log in to vote
1
Answered by
Evil2DS 25
5 years ago
01local rp = game.ReplicatedStorage
02local dark = rp:WaitForChild("Right Hand")
03 
04 
05game.Players.PlayerAdded:Connect(function(player)
06    player.CharacterAdded:connect(function(character)
07        character:WaitForChild("RightHand").Transparency = 0
08 
09        local ClonedRH = dark:Clone()
10        ClonedRH.Parent = character
11 
12        ClonedRH:SetPrimaryPartCFrame(character:WaitForChild("RightHand").CFrame)
13        local Weld = Instance.new("Weld")
14        Weld.Part0 = ClonedRH.Main
15        Weld.Part1 = character:WaitForChild("RightHand")
16        Weld.C0 = dark.PrimaryPart.CFrame * CFrame.Angles(0,0,0))
17        Weld.Parent = character:WaitForChild("RightHand")
18    end)
19end)   

Try this, the reason your code doesn't work is because SetPrimaryPartCFrame is not a CFrame value, rather it is a function.

0
it didnt work it just made the main part go up like 50 studs Fxding_cam 60 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

After SetPrimaryPart, try .Orientation if you're trying to rotate it then in the brackets put (0, whatever orientation it's at, 0). This work?

Answer this question