Im trying to make a custom hat to use in my game, i cannot figure out how to change its Y position value though
im using a server script inside of serverscriptservice, a remote is calling it, everything with the remote is fine.
-local rep = game:GetService("ReplicatedStorage")
rep.WHoodD.OnServerEvent:Connect(function(player, char)
for i, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
local clone = rep.Models.Hood:Clone()
clone.Parent = char
local weld = Instance.new("Weld")
weld.Parent = char.Head
weld.Part0 = clone.Hood1
weld.Part1 = char.Head
clone.Hood1.Anchored = false
end)
i’ve tried, it didnt work
this is the code i used with cframe
local rep = game:GetService("ReplicatedStorage")
rep.WHoodD.OnServerEvent:Connect(function(player, char)
for i, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
local clone = rep.Models.Hood:Clone()
local weld = Instance.new("Weld")
weld.Part0 = clone.Hood1
weld.Part1 = char.Head
local offsetCFrame = CFrame.new(0, 5, 0)
clone.Parent = char
local weld = Instance.new("Weld")
weld.Parent = char.Head
weld.Part0 = clone.Hood1
weld.Part1 = char.Head
clone.Hood1.CFrame = char.Head.CFrame:ToWorldSpace(offsetCFrame)
end)
local rep = game:GetService("ReplicatedStorage")
rep.WHoodD.OnServerEvent:Connect(function(player, char)
for i, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
local clone = rep.Models.Hood:Clone()
clone.Parent = char
local weld = Instance.new("Weld")
weld.Parent = char.Head
weld.Part0 = clone.Hood1
weld.Part1 = char.Head
clone.Hood1.Anchored = false
local hood1Pos = clone.Hood1.Position
local yOffset = 1 -- however much higher you want it to be
clone.Hood1.Position = Vector3.new(hood1Pos.X, hood1Pos.Y + yOffset, hood1Pos.Z)
end)
You added a hyphen before local in the first line.
local rep = game:GetService("ReplicatedStorage")
local WHoodD = rep:WaitForChild("WHoodD")
local hood = rep:WaitForChild("Models"):WaitForChild("Hood")
WHoodD.OnServerEvent:Connect(function(player, char)
for i, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
local clone = hood:Clone()
clone.Parent = char
local hood1 = clone:WaitForChild("Hood1")
local head = char:WaitForChild("Head")
local weld = Instance.new("Weld")
weld.Parent = head
weld.Part0 = hood1
weld.Part1 = head
hood1.Anchored = false
hood1.Position += Vector3.new(0, 1, 0)
end)
I’ve also done some cleaning up & added waits to make sure instances have loaded before the script executes.