So, i'm making a Singleplayer game where if you click it makes a part, But, I want you to be able to hold down MouseButton1 and parts to appear every 0.2 seconds, How would i fix that?
Here's my script
local lp = game.Players.LocalPlayer local rs = game:GetService("RunService") players = game:GetService("Players") --------------------------------------------- local mouse = lp:GetMouse() --------------------------------------------- script.Parent.Activated:Connect(function() local x = game.Workspace.Particle:Clone() x.Name = 'Parciclepart' x.Position = mouse.Hit.Position x.Parent = workspace end) ---------------------------------------------
Thanks for reading, Help it appreciated.
local Player = game:GetService("Players").LocalPlayer local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local mouse = Players:GetMouse() script.Parent.Activated:Connect(function() local pressed = true while pressed do -- repeat as long as the mouse button is pressed -- clone the part local x = workspace.Particle:Clone() x.Name = "ParticlePart" x.Position = mouse.Hit.Position x.Parent = workspace -- wait 0.2s local start = tick() repeat RunService.Stepped:Wait() until tick() - start > 0.2 -- check if the mouse button is pressed pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) end end)