I made this test weld script, and it works great, exactly how I wanted it to be. The problem is that the CFrame of the magic circle is literally on the character, and I want it to be where I said the circle's CFrame is in the script. I tried just circle.CFrame:inverse()
but that doesnt work. I cant think of anything else. Can anyone help me?
Yes, I know KeyDown is deprecated. I just used it as a quick test for this.
local plr = game.Players.LocalPlayer local char = game.Workspace:WaitForChild(plr.Name) local tool = script.Parent local CAS = game:GetService("ContextActionService") local Mouse = plr:GetMouse() local RootPart = char.HumanoidRootPart local ButtonDown = true local debounce = false local animation = script.Animation local hum = char.Humanoid local animTrack = hum:LoadAnimation(animation) function weld() if not debounce then debounce = true ButtonDown = true circle = game.ReplicatedStorage.circle:Clone() circle.Size = Vector3.new(10,10,0) circle.Parent = game.Workspace.fireball circle.Anchored = false circle.CanCollide = false circle.Transparency = 0 circle.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(10,0,0) local Weld = Instance.new("Weld") Weld.Parent = circle Weld.Part0 = circle Weld.Part1 = char.HumanoidRootPart Weld.C0 = circle.CFrame:inverse()*RootPart.CFrame bp = Instance.new("BodyPosition") bp.Parent = char.Torso bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge) bp.Position = char.Torso.Position bg = Instance.new("BodyGyro") bg.D = 100 bg.Parent = char.Torso bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge) char.Torso.CFrame = CFrame.new(char.Torso.Position, Mouse.Hit.p) while ButtonDown == true do bg.cframe = CFrame.new(char.Torso.Position, Mouse.Hit.p) animTrack:Play() wait() end wait(2) debounce = false end end Mouse.KeyDown:Connect(function(key) key = key:lower() if key == "u" then weld() end end) Mouse.KeyUp:Connect(function(key) key = key:lower() if key == "u" then ButtonDown = false animTrack:Stop() circle:Destroy() bg:Destroy() bp:Destroy() end end)
There are two problems here.
The first problem is the fact that you're setting Part0
to the circle and Part1
to the humanoid root part. While there is nothing inherently wrong with this, it would be more intuitive (and would make this easier to visualize) to set Part0
to humanoid root part and Part1
to the circle. As a rule of thumb, Part1
is the part you're attaching and Part0
is the part that Part1
is being attached to.
The second problem is the value you're setting to C0
. I see what you're trying to do but you're greatly overcomplicating the situation. The way I see it, you want the circle to be offset on the x axis by 10 studs relative to the humanoid root part (assumed because you did circle.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(10,0,0)
on line 25). In order to weld the circle to the humanoid root part in that relative position, simply set the C0
to CFrame.new(10,0,0)
. The C0
represents the cframe to hold Part1
in relative to Part0
.