Scripting ?skipping? check for bool value needing to be true, and skipping prints

My script is acting a little weird, so firstly my script is designed to check if a boolvalue is true, then play an animation. (the reason is because my animation plays weirdly, and it has to move seats, like the actual seat to play the animation is in the wrong place, so I have to make a seat to be a “decoy” then teleport the play to the real seat, and it shows as the correct place, I made a check script so they cant go into the real seat, and have to go into the “decoy” seat. That check script is acting weird.)

My real script contains this: (its not really a kick animation, I just wanna stick with roblox’s code so I dont mess anything up)

print("Scr INI")
local currentlySat = false
while wait(0.1) do
	if script.Parent.Occupant ~= nil then
		if script.Parent.CanSit.Value == true then
			local player = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
			local character = player.Character
			if not character or not character.Parent then
				character = player.CharacterAdded:Wait()
				local humanoid = character:WaitForChild("Humanoid")
				local animator = humanoid:WaitForChild("Animator")

				-- Create new "Animation" instance
				local kickAnimation ="Animation")
				-- Set its "AnimationId" to the corresponding animation asset ID
				kickAnimation.AnimationId = "rbxassetid://6920640725"

				-- Load animation onto the animator
				local kickAnimationTrack = animator:LoadAnimation(kickAnimation)

				-- Play animation track

				-- If a named event was defined for the animation, connect it to "GetMarkerReachedSignal()"

The decoy script contains this:

local cansit = workspace.Anim:WaitForChild("CanSit")
while wait(0.3) do
	if script.Parent.Occupant ~= nil then
		cansit.Value = true
		cansit.Value = false
		print("Cansit true and false")

I’ve looked all through the developer forum, I’ve seen posts like this, most of them didn’t have a solution, or weren’t helpful.

I’m not exactly sure whats going on, especially because it’s also doing this:
When I sit down, it prints that it changed the values in the decoy seat, and it also prints Sat, in the main script. It does not print Cansit, or print the value of it.

Make sure you’ve read my ENTIRE POST before saying anything, if you don’t understand, just reply, and thank you.

1 Like