Sitting Animation Scripts not working and doesn't give out any errors

Hello developers, I’m trying to make it where I have only one script that I only have to modify for player to have a proximity prompt seat with animations.

I don’t think this script it working and it didn’t give out any error in workspace either…

local anim = script.sitanim
local proximityPrompt = script.ProximityPrompt

function SeatScript(Seat)
	Seat.Changed:Connect(function(Prop)
		if Prop == "Occupant" then
			local hum = Seat.Occupant
			if hum then
				print(hum,anim)
				local Track = hum:LoadAnimation(anim)
				Track.Looped = true
				Track.Priority = Enum.AnimationPriority.Action
				proximityPrompt.Enabled = false
				Track:Play()
				spawn(function()
					repeat 
						wait()
					until Seat.Occupant == nil
					proximityPrompt.Enabled = true
					Track:Stop()
				end)
			end
		end
	end)

end
--------------
local WorkspaceChildren = workspace:GetDescendants()
for i, Seat in pairs (WorkspaceChildren) do
	if Seat.Name == "PromptSit" then
		script.ProximityPrompt:Clone().Parent = Seat
		script.sitanim:Clone().Parent = Seat

		--This will run your script when the server starts.
		SeatScript(Seat)
	end
end

Thank you so much for your help.

I tested the script here and it worked, the only thing I took away was proximityPrompt.Enabled because I don’t know what it is, but otherwise everything was ok, is your script in the ServerScriptService or in the Workspace?

It’s in server script service, do I have to change anything else?

No , I just changed that , maybe that 's what is giving the script problems , try to do a test with several prints and see how far the prints stop

I tried connecting them but can’t seem to acheive it, maybe it’s the functions within a function part?

it printed 1 and 2 btw

local anim = script.sitanim
local proximityPrompt = script.ProximityPrompt

function SeatScript(Seat)
	Seat.Changed:Connect(function(Prop)
		if Prop == "Occupant" then
			local hum = Seat.Occupant
			if hum then
				print(hum,anim)
				local Track = hum:LoadAnimation(anim)
				Track.Looped = true
				Track.Priority = Enum.AnimationPriority.Action
				proximityPrompt.Enabled = false
				Track:Play()
				spawn(function()
					repeat 
						wait()
					until Seat.Occupant == nil
					proximityPrompt.Enabled = true
					Track:Stop()
				end)
			end
		end
	end)
	
end
print(1)
--------------
local WorkspaceChildren = workspace:GetDescendants()
for i, Seat in pairs (WorkspaceChildren) do
	if Seat.Name == "PromptSit" then
		script.ProximityPrompt:Clone().Parent = Seat
		script.sitanim:Clone().Parent = Seat
print(2)
		--This will run your script when the server starts.
		proximityPrompt.Triggered:Connect(function(player)
			--			Seat:Sit(player.Character.Humanoid)
			spawn(SeatScript)
			SeatScript(Seat)
	print(3)
		end)
	end
end

the error is probably the name confusion , the proximity clone is not recognized , in other words it is recognizing the principal as the script 's child , try to place the clone as local and send it , something like
local newProximityPrompt = ProximityPrompt:Clone()

1 Like