Spawn script not working

I have a script in a part. I need an NPC to spawn on a player hit with that block. The script I have isn’t working, I have no idea why, please help

local S = script.Parent.Chicken
local Spaw = game.ReplicatedStorage.SpawnChick
local chicken = game.ReplicatedStorage.ChickenL4

local function SpawnChicken()
	local C = chicken:clone()
	C.Parent = workspace
	C.Position = game.Workspace.SpawnLocation.SpawnL4.Position
	S:Play()

	print("Spawned!")
end



script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		SpawnChicken()
	end
end)

Try this:

local S = script.Parent.Chicken
local Spaw = game.ReplicatedStorage.SpawnChick
local chicken = game.ReplicatedStorage.ChickenL4

function SpawnClicken(Instance)
local C = Instance:Clone()
C.Parent = workspace
C:SetPrimaryPartCFrame(workspace.SpawnLocation.SpawnL4.CFrame)
S:Play()

end


script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		SpawnChicken(chicken)
	end
end)
1 Like

Is the current script printing “Spawned!” when the player hits the pad?

Try setting the CFrame instead of position which is what you did here.

C.CFrame = workspace.SpawnLocation.SpawnL4.CFrame