Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i make a tool press repeatively when held down?

Asked by 4 years ago

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

01local lp = game.Players.LocalPlayer
02local rs = game:GetService("RunService")
03players = game:GetService("Players")
04 
05 
06 
07---------------------------------------------
08 
09local mouse = lp:GetMouse()
10 
11---------------------------------------------
12 
13script.Parent.Activated:Connect(function()
14    local x = game.Workspace.Particle:Clone()
15    x.Name = 'Parciclepart'
View all 21 lines...

Thanks for reading, Help it appreciated.

1 answer

Log in to vote
1
Answered by
Is_Hunter 152
4 years ago
Edited 4 years ago
01local Player = game:GetService("Players").LocalPlayer
02local RunService = game:GetService("RunService")
03local UserInputService = game:GetService("UserInputService")
04 
05local mouse = Players:GetMouse()
06 
07script.Parent.Activated:Connect(function()
08    local pressed = true
09    while pressed  do -- repeat as long as the mouse button is pressed
10        -- clone the part
11        local x = workspace.Particle:Clone()
12            x.Name = "ParticlePart"
13            x.Position = mouse.Hit.Position
14            x.Parent  = workspace
15 
View all 26 lines...
1
Thank you! EllaTheFloofyFox 106 — 4y
Ad

Answer this question