Physics issue with ragdolls

since my previous topic was closed for whatever reason, making a new one.

Basically, im trying to do client sided kill effects using NetworkOwnership. ( server kill effects are way too laggy.) When ragdolling, all the constraints are built correctly but the physics does not apply unless touched by another player.

Code and vide.

local event = script.Parent
local PlayerData = require(script.Parent.Parent.Parent.PlayerData.PlayerData)
local CommonServerFunctions = require(script.Parent.Parent.Parent.CommonServerFunctions)
local ServerData = require(script.Parent.Parent.Parent.ServerData)
local RagdollModule = require(game.ServerScriptService.General.DefaultRagdoll)
local DefaultKillEffect = require(game.ServerStorage.Content.Knives.StockKnife.KillEffect)

local function setRagdollOwnership(character)
	if character then
		for _, part in pairs(character:GetDescendants()) do
			if part:IsA("BasePart") then
				part:SetNetworkOwner(nil)
			end
		end
	end
end

event.Event:Connect(function(characterModel, knifeData, colorData, hitData)
	if knifeData.WasFused then
		knifeData.RealName = knifeData.Fused.ActualFuse
	end

	local selectedKillEffect
	local killEffectName
	local attacker = game.Players[characterModel.Name]

	local context = {
		player = attacker,
		KEffectFunctions = require(game.ServerScriptService.General.KEffectFunctions),
		HitData = hitData,
		ragdoll = RagdollModule
	}

	context.HitData.HitVelocity = CFrame.new(context.HitData.HitVelocity):Inverse().p

	for _, item in pairs(game.ServerStorage.Content:GetDescendants()) do
		if item.Name == knifeData.RealName then
			local killEffectFunc = require(item.KillEffect)
			if type(killEffectFunc) == "function" then
				killEffectName = knifeData.RealName
				selectedKillEffect = killEffectFunc
			end

			local gamepasses = PlayerData.ReadPlayerData(hitData.Attacker.UserId, { "Inventory", "Gamepasses" })
			for _, pass in pairs(gamepasses) do
				if pass.RealName == "KillEffectTransfer" then
					local equippedKnife = PlayerData.ReadPlayerData(hitData.Attacker.UserId, { "EquippedItems", "Knives", 1 })
					if equippedKnife.WasFused then
						equippedKnife = { RealName = equippedKnife.Fused.ActualFuse }
					end

					for _, knife in pairs(game.ServerStorage.Content.Knives:GetChildren()) do
						if knife.Name == equippedKnife.RealName then
							local altKillEffect = require(knife.KillEffect)
							if type(altKillEffect) == "function" then
								killEffectName = equippedKnife.RealName
								selectedKillEffect = altKillEffect
							end
							break
						end
					end

					break
				end
			end
		end
	end

	characterModel.Archivable = true
	local clonedCharacter = characterModel:Clone()
	characterModel:Destroy()
	characterModel = clonedCharacter
	characterModel.Parent = workspace
	characterModel.HumanoidRootPart.CFrame = CFrame.new(context.HitData.HitPosition)

	print(hitData)

	setRagdollOwnership(characterModel)

	game.ReplicatedStorage.GameEvents.KillEffect:FireAllClients(characterModel, context, killEffectName)
	script.Parent.Parent.PlayerDied:Fire(characterModel.Name)

	if selectedKillEffect then
		-- selectedKillEffect(characterModel, CommonServerFunctions, context, context.HitData)
	else
		-- DefaultKillEffect(characterModel, CommonServerFunctions, context, context.HitData)
	end
end)

  • Are you sure you are running this on a client?
  • ipairs/pairs is useless in Luau
  • dont use :SetNetwork on a client
  • Just make ragdoll get an attribute on whatever effect it must get

You’re telling that you are doing kill effects on a client but providing server-side code.

  • ???

the_scythe please don’t be a big brother challange (impossible)

1 Like

if i set the network owner to nil, the kill effect will not replicate physics (usually a ragdoll) unless i do it on the server, which has laggy physics and the client just calls the function for the kill effect, server just sets up character ownership and whatnot.