Currently working on a carrying system for my game, and everything works properly except the enemy characters rotation. This goes the same when testing on a player.And even from a players screen looks normal from both clients.I tried experimenting using setnetworkowner but i could not find a solution.
Any help?
btw the carrying uses align orientation and position
Here is the script along with an video:
GrabTrack = nil
GrabbedTrack = nil
-------------------------------------------------------------------------------------------------------------------------------------------
GrabbedList = { }
-------------------------------------------------------------------------------------------------------------------------------------------
CanGrab = true
function Grab(Part,Character,CharacterValue,player)
print("grab")
if Part.Parent.Name ~= Character.Name then
local Enemycharacter = Part.Parent
local Enemyplayer = game.Players:GetPlayerFromCharacter(Enemycharacter)
CharacterValue.GrabbedPlayer.Value = Enemycharacter
Enemycharacter.CharacterValues.GrabbedBy.Value = Character
if Enemyplayer then
GlobalEvents.Crippled:FireClient(Enemyplayer)
CharacterValue.GrabbedPlayer.Value = Enemycharacter
Enemycharacter.CharacterValues.GrabbedBy.Value = Character
else
end
Enemycharacter.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
Enemycharacter.HumanoidRootPart.Orientation = Vector3.new(90, 90, -180)
Character.UpperTorso.BodyFrontAttachment.Position = Vector3.new(-0.5,3,0)
Character.UpperTorso.BodyFrontAttachment.Orientation = Vector3.new(90, 90, -180)
local GrabbingAP = Instance.new("AlignPosition")
GrabbingAP.Parent = Enemycharacter.HumanoidRootPart
GrabbingAP.Name = "GrabbingAP"
GrabbingAP.Responsiveness = 200
GrabbingAP.MaxVelocity = math.huge
GrabbingAP.MaxForce = math.huge
GrabbingAP.RigidityEnabled = true
GrabbingAP.Attachment0 = Enemycharacter.UpperTorso.BodyFrontAttachment
GrabbingAP.Attachment1 = Character.UpperTorso.BodyFrontAttachment
local GrabbingAO = Instance.new("AlignOrientation")
GrabbingAO.Parent = Enemycharacter["UpperTorso"]
GrabbingAO.Name = "GrabbingAO"
GrabbingAO.RigidityEnabled = true
GrabbingAO.Attachment0 = Enemycharacter.UpperTorso.BodyFrontAttachment
GrabbingAO.Attachment1 = Character.UpperTorso.BodyFrontAttachment
Enemycharacter["UpperTorso"]:SetNetworkOwner(player)
game.ReplicatedStorage.GlobalEvents.Ragdoll:Fire(Enemycharacter,player,true)
local SelectedAnimation = CharacterValue.SelectedAnimation.Value
local SelectedAnimationTrack = script.Parent.Parent.Humanoid:LoadAnimation(SelectedAnimation)
GrabTrack = SelectedAnimationTrack
SelectedAnimationTrack:Play()
SelectedAnimationTrack.Stopped:Connect(function()
if CharacterValue.GrabbedPlayer.Value ~= nil then
LetGo(player)
end
end)
local SelectedAnimation = CharacterValue.SelectedBeingCarriedAnimation.Value
local SelectedAnimationTrack = Enemycharacter.Humanoid:LoadAnimation(SelectedAnimation)
GrabbedTrack = SelectedAnimationTrack
SelectedAnimationTrack:Play()
SelectedAnimationTrack:AdjustSpeed(2)
end
end
function LetGo(player)
print("let go")
local CharacterValue = player.Character:WaitForChild("CharacterValues")
local Character = player.Character
local Enemycharacter = CharacterValue.GrabbedPlayer.Value
if Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAP") then
Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAP"):Destroy()
end
if Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAO") then
Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAO"):Destroy()
end
local Enemyplayer = game.Players:GetPlayerFromCharacter(Enemycharacter)
CharacterValue.GrabbedPlayer.Value = Enemycharacter
Enemycharacter.CharacterValues.GrabbedBy.Value = Character
if Enemyplayer then
Enemycharacter["UpperTorso"]:SetNetworkOwner(Enemyplayer)
else
Enemycharacter["UpperTorso"]:SetNetworkOwner(nil)
end
game.ReplicatedStorage.GlobalEvents.Ragdoll:Fire(Enemycharacter,player,false)
CharacterValue.GrabbedPlayer.Value = nil
GrabbedTrack:Stop()
end
function Throw(player)
print("Throw")
local CharacterValue = script.Parent.Parent:WaitForChild("CharacterValues")
local Character = player.Character
local Enemycharacter = CharacterValue.GrabbedPlayer.Value
if Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAP") then
Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAP"):Destroy()
end
if Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAO") then
Enemycharacter.HumanoidRootPart:FindFirstChild("GrabbingAO"):Destroy()
end
local Enemyplayer = game.Players:GetPlayerFromCharacter(Enemycharacter)
if Enemyplayer then
Enemycharacter["UpperTorso"]:SetNetworkOwner(Enemyplayer)
else
Enemycharacter["UpperTorso"]:SetNetworkOwner(nil)
end
CharacterValue.GrabbedPlayer.Value = Enemycharacter
Enemycharacter.CharacterValues.GrabbedBy.Value = Character
GrabTrack:Stop()
local SelectedAnimation = CharacterValue.SelectedThrowAnimation.Value
local SelectedAnimationTrack = script.Parent.Parent.Humanoid:LoadAnimation(SelectedAnimation)
SelectedAnimationTrack:Play()
local ThrowVelocity = Instance.new("BodyVelocity")
ThrowVelocity.Parent = Enemycharacter.HumanoidRootPart
ThrowVelocity.P = 10000
ThrowVelocity.MaxForce = Vector3.new((math.huge),(math.huge),(math.huge))
local newPos = Character.HumanoidRootPart.CFrame.lookVector * 60 + Vector3.new(0,15,0)
ThrowVelocity.Velocity = newPos
game:GetService("Debris"):AddItem(ThrowVelocity,0.2)
game.ReplicatedStorage.GlobalEvents.Ragdoll:Fire(Enemycharacter,player,false)
CharacterValue.GrabbedPlayer.Value = nil
GrabbedTrack:Stop()
end
GrabEvent.OnServerEvent:Connect(function(player)
if CanGrab == false then
return
end
CanGrab = false
local CharacterValue = script.Parent.Parent:WaitForChild("CharacterValues")
local Character = player.Character
local Hitbox = SelectedHitbox:Clone()
Hitbox.Parent = Character
Hitbox.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2)
game:GetService("Debris"):AddItem(Hitbox,HitboxLifetime)
local HitboxWeld = Instance.new("WeldConstraint")
HitboxWeld.Parent = Tool
HitboxWeld.Name = "HitboxWeld"
HitboxWeld.Part0 = Character.HumanoidRootPart
HitboxWeld.Part1 = Hitbox
game:GetService("Debris"):AddItem(HitboxWeld,HitboxLifetime)
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = Hitbox
local zone = Zone.new(container)
local SelectedAnimation = game.ReplicatedStorage.GlobalAnimations.DefaultGrabbingAnimation
local SelectedAnimationTrack = script.Parent.Parent.Humanoid:LoadAnimation(SelectedAnimation)
SelectedAnimationTrack:Play()
zone.partEntered:Connect(function(Part)
if Part.Parent:FindFirstChild("CharacterValues") then
if table.find(GrabbedList,Part.Parent.Name) then
print("returned")
return
end
if Part.Parent.Name ~= Character.Name then
table.insert(GrabbedList, Part.Parent.Name)
Grab(Part,Character,CharacterValue,player)
Hitbox:Destroy()
end
end
end)
zone.partExited:Connect(function(Part)
if Part.Parent:FindFirstChild("CharacterValues") then
if table.find(GrabbedList,Part.Parent.Name) then
table.remove(GrabbedList, table.find(GrabbedList, Part.Parent.Name))
end
end
end)
wait(2.9)
if CanGrab == false then
CanGrab = true
end
end)
ThrowEvent.OnServerEvent:Connect(function(player)
Throw(player)
end)
script.Parent.ToolEvents.Sprint.OnServerEvent:Connect(function(player, params)
if params == "Sprint" then
if player.Character.HumanoidRootPart:FindFirstChild("RunSmog") then
player.Character.HumanoidRootPart:FindFirstChild("RunSmog").Enabled = true
return
end
local SMOG = script.Parent.ToolEffects.RunSmog:Clone()
SMOG.Parent = player.Character.HumanoidRootPart
SMOG.Enabled = true
else
if player.Character.HumanoidRootPart:FindFirstChild("RunSmog") then
player.Character.HumanoidRootPart:FindFirstChild("RunSmog").Enabled = false
end
end
end)