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)
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)