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

My script adds an accessory to my local player but it doesn't attach it to the head?

Asked by 6 years ago
Edited 6 years ago
01local helmet = script.Parent.Pikeman
02script.Parent.MouseButton1Click:connect (function ()
03 
04playername = script.Parent.Parent.Parent.Parent.Parent.Parent.Name
05player = Workspace:FindFirstChild(""..playername.."")
06if player ~= nil then
07        wait(0.1)
08        clonedObject = helmet:Clone()
09        wait(0.5)
10        clonedObject.Parent = player
11        player.Humanoid:AddAccessary(script.Parent.Pikeman)
12        print("Found Humanoid")
13        wait(0.2)
14 
15 
16    end
17end)

Any help appreciated thanks.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Courtesy of TheGamer101 on this DevForum post.

This is because Accessory welds are currently created on the server only, never the client. This is intended right now but we might change it to make this easier to work with when using FilteringEnabled.

Here is some code you can use to add an Accessory to a humanoid locally:

01function weldAttachments(attach1, attach2)
02    local weld = Instance.new("Weld")
03    weld.Part0 = attach1.Parent
04    weld.Part1 = attach2.Parent
05    weld.C0 = attach1.CFrame
06    weld.C1 = attach2.CFrame
07    weld.Parent = attach1.Parent
08    return weld
09end
10local function buildWeld(weldName, parent, part0, part1, c0, c1)
11    local weld = Instance.new("Weld")
12    weld.Name = weldName
13    weld.Part0 = part0
14    weld.Part1 = part1
15    weld.C0 = c0
View all 51 lines...

Using addAccoutrement(character, accoutrement) is how you would add it to the character. Character being your character and accoutrement being the Accessory.

Ad

Answer this question