hello my issue is a reoccuring thing where I want to get the new position of a hats handles after it has been repositioned relative to the “AccessoryWeld” which sits depending on what the accessory is. I’ve come to an abrupt stop in my script to where I reposition it and it starts to move sporadically and not to my desired direction.
tldr: hat moves to random direction after reposition, want to move relative to AccessoryWeld
AdornmentHandles.MouseButton1Up:Connect(function()
local A = HatHandle.AccessoryWeld.C0:ToObjectSpace(HatHandle.CFrame)
warn("Equation A = " .. A.X, A.Y, A.Y)
local X = A.X
local Y = A.Y
local Z = A.Z
local B = HatHandle.AccessoryWeld.C0:ToObjectSpace(A)
warn("Equation B = " .. B.X, B.Y, B.Z)
local NewX = B.X - origin.X
local NewY = B.Y - origin.Y
local NewZ = B.Z - origin.Z
local NewPosition = CFrame.new(NewX, NewY, NewZ)
print("The added position is now " .. NewPosition.Position.X, NewPosition.Position.Y, NewPosition.Position.z)
warn("Position from equation A = " .. X,Y,Z)
warn("Position from equation B = " .. NewX, NewY, NewZ)
ReplicatedStorage.Customization.PositionCheck:FireServer(NewPosition, Hat)
HatHandle.AccessoryWeld.Enabled = true
HatHandle.Anchored = false
X = 0
Y = 0
Z = 0
NewX = 0
NewY = 0
NewZ = 0
NewPosition = nil
B = nil
A = nil
end)
also on a side note the person who replied to you above posts nothing but nonsensical ai generated responses, none of the apis they suggest actually exist, so it’s best to ignore them
I’d calculate the C0 on the client, then use your remote to send it to the server, and on the server set the weld’s C0 using the C0 sent from the client, ie
local targetC0 = ((weld.Part1.CFrame * weld.C1):Inverse() * handle.CFrame):Inverse()
ReplicatedStorage.Customization.PositionCheck:FireServer(targetC0, Hat)
on server:
remote.OnServerEvent:Connect(function(player, c0, hat)
local weld = hat:FindFirstChild('AccessoryWeld')
if weld then
weld.C0 = c0
end
end
Thank you it works, however it seems the reset the axis I last editted it on, and what I mean that is, if I edit the X axis, its fine, however when I edit the Z axis, the X axis is resetted to 0, and the Z axis works fine.
would I have to get each individual position (X, Y, Z) then send it through the remote for it to work?
also here’s a video of the system, theres a few mishaps like what I stated above, but also some of the hats go opposite directions of where I desire it to go, and such more.
You’d do it on mouse button down (AdornmentHandles.MouseButton1Down:Connect(...), not up, so it should be an entirely separate connection from the one where you’re firing the remote