I have a pickup system where if a player is knocked they can get picked up. The problem is that when a player resets, they only die when the other player drops them.
CARRYING LOCAL SCRIPT below
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local debounce = false
local pressed = false
local Mouse = player:GetMouse()
repeat wait() until player.Character
Character = player.Character
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
if pressed ==false and debounce == false then
pressed = true
debounce = true
script.RemoteEvent:FireServer(Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3).p,"PickUp")
print("Pick up Player.")
wait(.5)
debounce = false
elseif pressed == true and debounce == false then
debounce = true
script.RemoteEvent:FireServer(Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3).p,"Drop")
print("Drop Player.")
pressed = false
wait(.5)
debounce = false
end
end
player.Character.Humanoid.Died:Connect(function()
script.RemoteEvent:FireServer(Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3).p,"Drop")
end)
end)
player.Character.Values.Downed.Changed:Connect(function()
wait()
if player.Character.Values.Downed.Value == true then
script.RemoteEvent:FireServer(Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3).p,"Drop")
end
end)
workspace.ChildRemoved:Connect(function(plr)
if plr == Character then
script.RemoteEvent:FireServer(Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3).p,"Drop")
end
end)
server script inside carrying below
local enemychar
local anim2
local anim3
local carryingvalue
local enemyplayer
script.Parent.OnServerEvent:Connect(function(player,V1,Value)
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
if Value == "PickUp" then
local region = Region3.new(V1-Vector3.new(2,5,2),V1+Vector3.new(2,5,2))
local RTable = workspace:FindPartsInRegion3(region,nil,20)
for i,v in pairs(RTable) do
if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= char then
enemychar = v.Parent
if enemychar.Humanoid.Health >=35 then
return
end
if char.Values.Carrying.Value == true then
return
end
enemyplayer = game.Players:GetPlayerFromCharacter(enemychar)
if enemychar.Values.ReadytoCarry.Value == true then
if enemychar.Humanoid.Health >=0 then
local root = enemychar.HumanoidRootPart
root.Anchored = false
--enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.Scriptable
local Weld = Instance.new("Weld")
enemychar.HumanoidRootPart:SetNetworkOwner(player)
Weld.Part0=char.Torso;Weld.Part1=enemychar.HumanoidRootPart;Weld.C0=CFrame.new(0.1,.25,-0.35);Weld.Name="gripweld";Weld.Parent=enemychar.HumanoidRootPart
enemychar.Humanoid.Died:Connect(function()
if char.Values.Carrying.Value == true then
if enemychar.Values.BeingCarry.Value == true then
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
enemychar.HumanoidRootPart.gripweld:Destroy()
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
anim2:Stop()
anim3:Stop()
enemychar.Humanoid.PlatformStand=false
enemychar.Head.CanCollide = true
enemychar.Torso.CanCollide = true
char.Values.Carrying.Value = false
enemychar.Values.ReadytoCarry.Value = true
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
-- enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
end
end
end)
enemychar.Values.ReadytoCarry.Value = false
enemychar.Values.BeingCarry.Value = true
char.Values.Carrying.Value = true
enemychar.Head.CanCollide = false
enemychar.Torso.CanCollide = false
enemychar.Humanoid.PlatformStand=true
enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.Scriptable
local track2 = Instance.new("Animation")
track2.AnimationId = "rbxassetid://10762898142"
anim2 = enemychar.Humanoid:LoadAnimation(track2) --enemy on back animation
anim2:Play()
local track3 = Instance.new("Animation")
track3.AnimationId = "rbxassetid://10762888590"
anim3 = char.Humanoid:LoadAnimation(track3) -- Me carrying him animation
anim3:Play()
enemychar.Head.CanCollide = false
enemychar.Torso.CanCollide = false
end
game.Players.PlayerRemoving:Connect(function(e)
if e.name == enemyplayer.Name and enemychar.Values.BeingCarry.Value == true then
if char.Values.Carrying.Value == true then
if enemychar.Values.BeingCarry.Value == true then
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
enemychar.HumanoidRootPart.gripweld:Destroy()
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
anim2:Stop()
anim3:Stop()
enemychar.Humanoid.PlatformStand=false
enemychar.Head.CanCollide = true
enemychar.Torso.CanCollide = true
char.Values.Carrying.Value = false
enemychar.Values.ReadytoCarry.Value = true
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
-- enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
end
end
end
end)
if enemychar.Humanoid.Health >=35 and enemychar.Humanoid.Health >=0 and enemychar.Values.BeingCarry.Value == true then
-- if enemychar.Massless then
-- enemychar.Massless = true
-- end
if char.Values.Carrying.Value == true then
if enemychar.Values.BeingCarry.Value == true then
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
enemychar.HumanoidRootPart.gripweld:Destroy()
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
anim2:Stop()
anim3:Stop()
enemychar.Humanoid.PlatformStand=false
enemychar.Head.CanCollide = true
enemychar.Torso.CanCollide = true
char.Values.Carrying.Value = false
enemychar.Values.ReadytoCarry.Value = true
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
-- enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
else
if enemychar.Values.BeingCarry.Value == true then
if char.Values.Carrying.Value == true then
if enemychar.Values.BeingCarry.Value == true then
enemychar.HumanoidRootPart.gripweld:Destroy()
enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
anim2:Stop()
anim3:Stop()
enemychar.Humanoid.PlatformStand=false
enemychar.Head.CanCollide = true
enemychar.Torso.CanCollide = true
char.Values.Carrying.Value = false
enemychar.Values.ReadytoCarry.Value = true
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
end
end
end
end
end
end
end
end
end
elseif Value == "Drop" then
if char.Values.Carrying.Value == true then
if enemychar.Values.BeingCarry.Value == true then
-- enemychar.HumanoidRootPart:SetNetworkOwner(enemyplayer)
if not enemychar.Humanoid then
repeat wait() until enemychar.Humanoid
enemychar.Humanoid.PlatformStand=false
else
enemychar.Humanoid.PlatformStand=false
end
if not enemychar.HumanoidRootPart then
repeat wait() until enemychar.HumanoidRootPart
if not enemychar.HumanoidRootPart.gripweld then
repeat wait() until enemychar.HumanoidRootPart.gripweld
enemychar.HumanoidRootPart.gripweld:Destroy()
end
else
enemychar.HumanoidRootPart.gripweld:Destroy()
end
anim2:Stop()
anim3:Stop()
enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
enemychar.Head.CanCollide = true
enemychar.Torso.CanCollide = true
enemychar.Values.ReadytoCarry.Value = true
char.Values.Carrying.Value = false
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
-- if enemychar.Massless then
-- enemychar.Massless = true
-- end
-- enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
enemychar.Humanoid.PlatformStand=false
else
-- if enemychar.Massless then
-- enemychar.Massless = true
-- end
if enemychar.HumanoidRootPart:FindFirstChild("gripweld") then
enemychar.HumanoidRootPart.gripweld:Destroy()
enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
anim2:Stop() -- enenmy on back
anim3:Stop() -- me carrying
enemychar.Humanoid.PlatformStand=false
enemychar.HumanoidRootPart.Anchored = false
enemychar.Values.ReadytoCarry.Value = true
enemychar.Values.BeingCarry.Value = false
enemychar.Humanoid.WalkSpeed = 2
-- enemyplayer.DevComputerMovementMode = Enum.DevComputerMovementMode.UserChoice
end
end
end
end
end)
You are able to see my failed attempts in the server script lol.
Why does the player only die when they’re put down?