-- Variables local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local TrainRemote = ReplicatedStorage.Train.Remote.TrainAnimeHasEnded -- State local isToggled = false local loopConnection -- Function to toggle the loop local function toggleLoop() isToggled = not isToggled if isToggled then -- Start the loop loopConnection = game:GetService("RunService").Heartbeat:Connect(function() TrainRemote:FireServer() wait(0.1) -- Adjusts the activation rate end) else -- Stop the loop if loopConnection then loopConnection:Disconnect() loopConnection = nil end end end -- Listen for the T key press UserInputService.InputBegan:Connect(function(input, isProcessed) if not isProcessed and input.KeyCode == Enum.KeyCode.T then toggleLoop() end end)