Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Postioning weld doesn't work either does rotating?

Asked by 3 years ago
Edited 3 years ago

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()

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

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.

0
Thanks ill test it when i have time IEntity_303I 80 — 3y
0
tysm IEntity_303I 80 — 3y
0
tysm IEntity_303I 80 — 3y
Ad

Answer this question