Script Acting Weird

Ok, so basically I clone a folder into the players character. But when I trigger a proximity prompt, the script errors. It basically says that the folder does not exist in my character, but it does. I clone the folder by a GUI when clicked, which seems to work.

local whispers = script.Parent.Parent.whispers
local explosion = script.Parent.Parent.explosion
local commonchiiken = script.Parent.Parent.Parent.CommonChiiken
local fard = script.Parent.Parent.fard
local pointlight = script.Parent.Parent.Parent.Black.PointLight



script.Parent.Triggered:Connect(function(player)
	print("activated")
	local char = player.Character
	local ticket = char.CommonTicket -- where it errors
	local pets = player:WaitForChild("Pets")
	local leaderstats = player:WaitForChild("leaderstats")
	local chiikens = leaderstats:WaitForChild("Chiikens")
	local ccvalue = pets:WaitForChild("CommonChiiken")

	if ticket.ClassName == "Folder" then -- does not fire
		print("true")
		script.Parent.Enabled = false
		for count = 0.5,10,0.1 do
			whispers.Volume = count
			wait(0.1)
		end
		explosion:Play()
		repeat
			game.Workspace.Shake.Value += 1
			wait(0.1)
		until
		game.Workspace.Shake.Value == 2
		whispers:Stop()
		wait(2)
		fard:Play()
		commonchiiken.Anchored = false
		chiikens.Value -= 0
		ccvalue.Value = true
		wait(35)
		commonchiiken.Anchored = true
		commonchiiken.Position = Vector3.new(125.906, 29.54, 294.668)
		whispers:Play()
		whispers.Volume = 0.5
		script.Parent.Enabled = true
	else
		local a = 0
		print("false")
		explosion:Play()
		repeat 
			a += 1
			pointlight.Enabled = true
			wait(1)
			pointlight.Enabled = false
			wait(1)
		until
		a == 5
		a = 0
	end
end)

It would be helpful to see the code that generates the folder into the player’s character. This could be a problem with a player resetting and the folder not regenerating. Maybe store it in the player itself, not the character.

1 Like

Hi. Please manually check if the folder exists in the player character by running the playtest
image
find your character and see if the folder exists there.

How are you cloning the script? Is it necessary to have a separate script add the script to the character, or can you just place the script inside StarterCharacterScript?
image