local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local holding = false -- Detect when P is pressed UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.P then holding = true -- Start loop in a separate thread task.spawn(function() while holding do ReplicatedStorage:WaitForChild("SpawnGalaxyBlock"):FireServer() task.wait(0.01) -- adjust delay if you want it faster/slower end end) end end) -- Detect when P is released UserInputService.InputEnded:Connect(function(input, gameProcessed) if input.KeyCode == Enum.KeyCode.P then holding = false end end)