i made a visualizer for my game that would be under the player but it doesn't work it just basically is the same weld rotation and position nothing changed at all.
local radio = script.Parent local weld2 = Instance.new("Weld") local Spectrum = game.ReplicatedStorage.Parts.Spectrum:Clone() Spectrum.Parent = radio.mesh Spectrum.Position = Player.Character.HumanoidRootPart.Position + Vector3.new(0,-6,0) weld2.Parent = Player.Character.HumanoidRootPart weld2.Name = "Spectrum_Weld" weld2.Part0 = Player.Character.HumanoidRootPart weld2.Part1 = Spectrum weld2.C0 = Player.Character.HumanoidRootPart.CFrame:Inverse() weld2.C1 = Spectrum.CFrame:Inverse()
Here is what you have to fix.
local radio = script.Parent local weld2 = Instance.new("Weld") local Spectrum = game.ReplicatedStorage.Parts.Spectrum:Clone() Spectrum.Parent = radio.mesh Spectrum.Position = Player.Character.HumanoidRootPart.Position + Vector3.new(0,-6,0) weld2.Name = "Spectrum_Weld" weld2.Part0 = Player.Character.HumanoidRootPart weld2.Part1 = Spectrum weld2.C0 = Player.Character.HumanoidRootPart.CFrame:Inverse()*CFrame.new(Player.Character.HumanoidRootPart.Position) weld2.C1 = Spectrum.CFrame:Inverse()*CFrame.new(Player.Character.HumanoidRootPart.Position) weld2.Parent = Player.Character.HumanoidRootPart
Edit: Sorry, here is explaination:
Here is your script:
weld2.C1 = Spectrum.CFrame:Inverse()
This is just the Inverse of Spectrum's CFrame Ex. 1 -> -1 , -3 -> 3
The correct should be distance between 2 parts that is welded. 1.) Find the first position. (in the form of CFrame)
local FirstPosition = Player.Character.HumanoidRootPart.Position CFrame.new(FirstPosition)
2.) Subtract the first position with the second position. To subtract the cframe, yoou will need to inverse the cframe first and then sum it.
local FirstPosition = Player.Character.HumanoidRootPart.Position CFrame.new(FirstPosition) * Spectrum.CFrame:Inverse() --or Spectrum.CFrame:Inverse() * CFrame.new(FirstPosition)
Now you got the distance between 2 parts, put it in weld.C1 because the center position of the weld(0, 0, 0) is weld.Part0 Position.