Script works in every mode except test mode

You can write your topic however you want, but you need to answer these questions:

  1. I’m trying to make a force script that pretty much already works. Keep it simple and clear!

  2. **I cannot test it using “Test Mode” ** Include screenshots / videos if possible!
    image

  3. I’ve tried moving the script, looked for solutions, nothing. Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local player = game:GetService("Players").LocalPlayer
local forcelocked = nil
local mouse = player:GetMouse()
local hum = player.Character:WaitForChild("Humanoid")
local a = Instance.new("Animation")
a.AnimationId = "rbxassetid://11638837426"
local anim = hum:WaitForChild("Animator"):LoadAnimation(a)
local UserInputService = game:GetService("UserInputService")
anim:GetMarkerReachedSignal("ArmRisen"):Connect(function()
	anim:AdjustSpeed(0)
end)
if player:GetRankInGroup(16281209) >= 253 then
UserInputService.InputEnded:Connect(function(input,gameprocessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if forcelocked ~= nil then
				forcelocked = nil
				anim:AdjustSpeed(1)
			return
		end
		pcall(function()
			if mouse.Target.Parent:FindFirstChild("Humanoid") then
					print("locked player in")
					anim:Play()
					forcelocked = mouse.Target.Parent
				else
					print("WORKKKK")
			end
		end)
	end
end)
UserInputService.InputChanged:Connect(function(input,gameprocessed)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		if forcelocked ~= nil then
			local ray = workspace.CurrentCamera:ViewportPointToRay(mouse.X, mouse.Y)
			game.ReplicatedStorage.Force:FireServer(forcelocked,ray)
		end
		pcall(function()
			if mouse.Target.Parent:FindFirstChild("Humanoid") == nil then 
				if mouse.Target and mouse.Target.Parent then
					--print("not found")
					--print(mouse.Target.Parent)
				end
			end 
			if mouse.Target.Parent:FindFirstChild("Humanoid") ~= nil then
				print("I guess i found a humanoid?")
				end
			end)
		end	
	end)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.