So recently i modeled a mask for my game and made a wear button gui to go with it, but i have encountered an issue where it does parent the accessory to my character but it does not attach to it… It just falls and when i jump it pushes me away. No idea why this is happening since i am new to creating my own in game accessories.
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
script.Parent.MouseButton1Click:Connect(function()
local mask = game.ReplicatedStorage["Mask"]
if char:FindFirstChild("Mask") then
char:FindFirstChild("Mask"):Destroy()
else
local mask = game.ReplicatedStorage["Mask"]
mask:Clone().Parent = char
end
end)
Does the accessory have an attachment in the Handle with the same name as one of the attachments in the character?
For example, my accessory has an attachment with the name “HatAttachment” which means the game will make a weld from the accessory attachment to the attachment with the same name in the character
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
script.Parent.MouseButton1Click:Connect(function()
local mask = game.ReplicatedStorage["Mask"]
if char:FindFirstChild("Mask") then
char:FindFirstChild("Mask"):Destroy()
else
local mask = game.ReplicatedStorage["Mask"]
char:FindFirstChild("Humanoid"):AddAcessory(mask:Clone())
end
end)
I think I found your problem: the script that gives the accessory is local so it doesn’t replicate to the server. Maybe put a remote event in replicated storage and add a script in ServerScriptService.
And add this into the script in ServerScriptService:
local mask = game.ReplicatedStorage.Mask
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(player)
if player.Character:FindFirstChild("Mask") then
player.Character.Mask:Destroy()
else
mask:Clone().Parent = player.Character
end
end)