So I am working on a hat giver for my game, but the hat will not move to the players head, can someone explain why please?
function GiveHat(Character)
Character.Humanoid:RemoveAccessories()
local HatCFrame = CFrame.new(Character.Head.Position)
local LookAt = CFrame.lookAt(Character.Head.Position, Character.Head.CFrame.LookVector)
local MainCFrame = CFrame.new(HatCFrame, LookAt)
local HatToGive = script.Parent.Main:Clone() HatToGive.Parent = Character
HatToGive:SetPrimaryPartCFrame(MainCFrame)
end
Your console might be able to explain why; and if not, then you should be able to do that. We can’t exactly handle the explaining part for you, that’s on you. We need context so we can better help you. Why does your hat giver not work? What’s the exact problem? Also, have you tried applying any basic debugging if it happens to be a script issue?
function GiveHat(Character)
Character.Humanoid:RemoveAccessories()
local HatCFrame = Vector3.new(Character.Head.Position)
local LookAt = CFrame.lookAt(Character.Head.Position, Character.Head.CFrame.LookVector)
local MainCFrame = CFrame.new(HatCFrame, LookAt)
local HatToGive = script.Parent.Main:Clone() HatToGive.Parent = Character
HatToGive:SetPrimaryPartCFrame(MainCFrame)
end
local function GiveHat(Character)
Character.Humanoid:RemoveAccessories()
local MainCFrame = CFrame.lookAt(Character.Head.Position, Character.Head.CFrame.LookVector)
local HatToGive = script.Parent.Main:Clone()
HatToGive.Parent = Character
HatToGive:PivotTo(MainCFrame)
end