I need help making a ability that summons a soldier

I have the script for the soldier I just need help for the cloning part.
Right now, when I test the ability, the soldier summons in the wrong location and I need it to be at the current location the player is at.

-- CLONE SCRIPT btw
local event = game:GetService("ReplicatedStorage").BugleCombo

local plr = game.Players.PlayerAdded:Wait()

local char = plr.Character or plr.CharacterAdded:Wait()


local pos = char:WaitForChild("HumanoidRootPart").CFrame


event.OnServerEvent:Connect(function()
	local clone = game:GetService("ReplicatedStorage"):WaitForChild("Soldier"):Clone()
	clone.Parent = workspace 
	clone:WaitForChild("HumanoidRootPart").CFrame = pos
	wait(4)
	clone:Destroy()

end)

Example of the situation:


(The soldier summoned behind the player, I don’t want that)

Who are you trying to find by doing?

local plr = game.Players.PlayerAdded:Wait()

If you are attempting to clone the player, be aware that the first parameter of OnServerEvent will always be the player who sent the signal to the server.

event.OnServerEvent:Connect(function(player)
	local char = player.Character
	if char then
		local pos = char:WaitForChild("HumanoidRootPart").CFrame

		local clone = game:GetService("ReplicatedStorage"):WaitForChild("Soldier"):Clone()
		clone.Parent = workspace 
		clone:WaitForChild("HumanoidRootPart").CFrame = pos
		wait(4)
		clone:Destroy()
	else
		warn("No character found for "..player.Name)
	end
end)

wow can’t believe it was that simple thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.