To simplify my title, make it understandable : I have a script which spawns a wall of an attack and should supposedly spawn it on the humanoid/boss and be the same rotation/cframe, However I don’t know how to do this? since it is a model I don’t know how to rotate it within a script to copy the parent’s CFrame.
This is the script.
local tool = script.Parent
repeat task.wait() until script.Parent
local targetfound = false
repeat task.wait() until script.Parent.Name ~= "SansAttacks"
local mag = 4000
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
--================TargetPosition========================
local players = game.Players:GetChildren()
local range = 300
local lastmag= 1000
local mTorso = script.Parent:FindFirstChild("Torso")
local mHum = script.Parent:FindFirstChild("Humanoid")
for i=1,#players do
task.wait()
if players[i].Character then
local char = players[i].Character
if char:FindFirstChild("Torso") then
local Torso = char:FindFirstChild("Torso")
local mag = (Torso.Position - script.Parent.Torso.Position).magnitude
if mag<=range then
if char.Name ~= script.Parent.Parent then
if mag < lastmag then
mag = (Torso.Position - script.Parent.Torso.Position).magnitude
lastmag = mag
TargetPosition = Vector3.new(Torso.Position.x,Torso.Position.y -1,Torso.Position.z)
targetfound = true
end
end
end
end
end
end -- end of for loop
--==========================
if targetfound == true then
local BoneType = 1
local Bones = game.ServerStorage.SansAttacks.BonePush.BonePush:Clone()
Bones.Owner.Value = script.Parent.Name
Bones.Parent = game.Workspace
Bones:SetPrimaryPartCFrame(CFrame.new(mTorso.position.X, mTorso.position.Y ,mTorso.position.Z))
local Center = Bones:GetPrimaryPartCFrame()
local DirectionVector3 = Center:vectorToWorldSpace(Vector3.new(0,0,0)) -- (+)left or (-)right
if BoneType == 1 then
DirectionVector3 = Center:vectorToWorldSpace(Vector3.new(0,0,-30))
end
Bones.Decay.Disabled =false
end
script:Destroy()
This is the main position stuff.
if targetfound == true then
local BoneType = 1
local Bones = game.ServerStorage.SansAttacks.BonePush.BonePush:Clone()
Bones.Owner.Value = script.Parent.Name
Bones.Parent = game.Workspace
Bones:SetPrimaryPartCFrame(CFrame.new(mTorso.position.X, mTorso.position.Y ,mTorso.position.Z))
local Center = Bones:GetPrimaryPartCFrame()
local DirectionVector3 = Center:vectorToWorldSpace(Vector3.new(0,0,0)) -- (+)left or (-)right
if BoneType == 1 then
DirectionVector3 = Center:vectorToWorldSpace(Vector3.new(0,0,-30))
end
Bones.Decay.Disabled =false
end
mTorso is the torso of the humanoid/boss so how do I make the Bones which is a model copy its rotation? Help would be appreciated thank you.