I am trying to change the position of a hat accessory on my player character. However, a change in the position property does not correlate to any visual change. I have no idea why and don’t know how to fix this.
The AttachmentPoint.Property value is changing, but no visual change occurs.
My code works with a ServerScript and a ModuleScript.
Server Script:
local PlayerService = game:GetService("Players")
local HatModule = require(game.ReplicatedStorage.Common.HatModule)
PlayerService.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local clone = game.ReplicatedStorage["Top Hat"]:Clone()
clone.Parent = character
end)
player.Chatted:Connect(function(message)
HatModule.SetHatHeight(player.Character, message)
player.Character["Top Hat"].AttachmentPoint = player.Character.Head.HatAttachment.CFrame
end)
end)
Module Script:
local HatModule = {}
function HatModule.SetHatHeight(character, offset)
character.Head.HatAttachment.CFrame = CFrame.new(0, tonumber(offset)+0.57, 0)
--character["Top Hat"].AttachmentPoint.Position.Y = tonumber(offset)
character["Top Hat"].AttachmentForward = character.Head.HatAttachment.CFrame.Position
end
return HatModule