Need help with an appearing NPC script

So firstly, everything in this script works as normal except it does not clone the NPC “Girl” from ReplicatedStorage.

Here is the script:

local part = script.Parent
local RS = game:GetService(“ReplicatedStorage”)
local NPC = RS.Girl
local animationID = 9682097073
local trigger = script.Parent

local trigHit = false

part.Touched:connect(function(hit)
game.workspace[“Fold Trigger (xd)”].Sound:Play()
if hit.Parent:FindFirstChild(“Humanoid”) ~= nil then --checks if hit is a player
local Animation = Instance.new(“Animation”,NPC)
Animation.AnimationId = “http://www.roblox.com/Asset?ID=”…animationID
local LoadedAnimation = NPC.Humanoid:LoadAnimation(Animation)
game.Workspace[“Fold Trigger (xd)”].CanTouch = false
game.workspace.L1.PointLight.Enabled = false
wait(0.03)
game.workspace.L1.PointLight.Enabled = true
wait(0.1)
game.workspace.L1.PointLight.Enabled = false
wait(1)
game.workspace.L2.PointLight.Enabled = false
wait(1.2)
game.workspace.L3.PointLight.Enabled = false
wait(1.1)
game.workspace.L4.PointLight.Enabled = false
LoadedAnimation:Play()
wait(0.2)
for i,v in pairs(workspace.Girl2:GetChildren()) do
v.Transparency = 0
wait(0.1)
v.Transparency = 1

	end

	trigger.Touched:Connect(function()

		if trigHit == false then
			trigHit = true
			local clone = NPC:Clone()
			clone.Parent = game.Workspace
			game.Debris:AddItem(clone, 3)
		end
	end)



end

end)

Does anyone see the issue on why it will not clone the “Girl” from ReplicatedStorage into workspace?

I’m newer to scripting.

try this

if trigHit == false then
            print("it gets to this point")
			trigHit = true
			local clone = NPC:Clone()
			clone.Parent = game.Workspace
			game.Debris:AddItem(clone, 3)
		end

if it doesn’t print “it gets to this point” that means the code isnt running, so either trigHit is false or trigger.touched isnt running

1 Like

Also keep in mind you are removing it 3 seconds later.

Thanks! Fixed the positioning of that portion of the script and it works!

1 Like