Code issues - dummy player position when die

Hi guys, I would like to make ‘thisdummy’ appear in the workspace at the player position, how do I do it? What am I doing wrong in my code? :frowning:

script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.Died:Connect(function(plr)
			local humanoid = script.Parent.Humanoid
			local desc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
			humanoid:ApplyDescription(desc)
			local dm = game.ReplicatedStorage.THISDUMMY:Clone()
			dm.Parent = workspace
		end)
	end)
end)

image

2 Likes

I think you need another string saying:
dm.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame

like this?

local humanoid = script.Parent.Humanoid
			local desc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
			humanoid:ApplyDescription(desc)
			local dm = game.ReplicatedStorage.THISDUMMY:Clone()
			dm.Parent = workspace
			dm.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame
2 Likes

Yes because it tells the script to position the dummy where the player’s character is.

1 Like

It did not work, when I die it is not cloned and the dummy does not appear in my position or in any part of the workspace

Are there any errors in the output?

No errors in console… I put a print and it is not shown in console either

script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.Died:Connect(function(plr)
			local humanoid = script.Parent.Humanoid
			local desc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
			humanoid:ApplyDescription(desc)
			local dm = game.ReplicatedStorage.THISDUMMY:Clone()
			dm.Parent = workspace
			dm.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame
			print("cloned!!")
		end)
	end)
end)
1 Like

Ok so after a bit of testing I fixed the problem. I basically moved the script into the ServerScriptService and made a few changes to it. Here’s what it looks like:

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
	character.Humanoid.Died:Connect(function(plr)
		local dm = game:GetService("ReplicatedStorage"):FindFirstChild("THISDUMMY"):Clone()
		print("cloned!!")
		dm.Parent = workspace
		dm:FindFirstChild("HumanoidRootPart").CFrame = character.HumanoidRootPart.CFrame
	end)
end)

end)

This works for me.

1 Like

Works!

but how can i add this to the script?

local humanoid = dummyhumanoidhere
local desc = game.Players:GetHumanoidDescriptionFromUserId(plr.UserId)
humanoid:ApplyDescription(desc)

Try this:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.Died:Connect(function(plr)
			local dm = game:GetService("ReplicatedStorage"):FindFirstChild("THISDUMMY"):Clone()
			print("cloned!!")
			dm.Parent = workspace
			dm:FindFirstChild("HumanoidRootPart").CFrame = character.HumanoidRootPart.CFrame
			local humanoid = dm.Humanoid
			local desc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
			humanoid:ApplyDescription(desc)
		end)
	end)
end)
1 Like

It worked!! many thanks :smiley: :smiley: :smiley: really thank you very much for your time and sorry for the inconvenience

1 Like