Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make the part increase in size while you hold down left click?

I am trying to make this move "Chargeable" so basically I just want the part to continue to grow while you have left click pressed down. Then when you lift up your left click, the part will go forward.

Here is the code I have so far

local Player = script.Parent.Parent.Parent
local bin = script.Parent
local Torso = Player.Character:WaitForChild("Torso")
local Mouse = Player:GetMouse()

enabled = true
debounce = true

function onButton1Down(mouse)
	
 
	wait(.2)
 local x = script.Part:Clone()
  x.Parent = game.Workspace
  x.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,-10) 
  x.Size = Vector3.new(10,10,0)
  x.Anchored = false
  x.CanCollide = false
  local Velocity = Instance.new("BodyVelocity", x)
  Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  Velocity.velocity = Player.Character.Torso.CFrame.lookVector*40
	fd = script.Firedamage:Clone()
	fd.Parent = x
	
 wait(5)
 x:remove()

wait(5)
 

end



function onS(mouse) 
mouse.Button1Down:connect(function() onButton1Down(mouse) end) 
end 
bin.Selected:connect(onS)

1 answer

local Player = script.Parent.Parent.Parent
local bin = script.Parent
local Torso = Player.Character:WaitForChild("Torso")
local Mouse = Player:GetMouse()

enabled = true
charging = false --a bool value for the charging
debounce = true

function onButton1Down(mouse)


    wait(.2)
charging() --Runs the function charging
charging = true --Sets charging to true
 local x = script.Part:Clone()
  x.Parent = game.Workspace
  x.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,-10) 
  x.Size = Vector3.new(10,10,0)
  x.Anchored = false
  x.CanCollide = false
  local Velocity = Instance.new("BodyVelocity", x)
  Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  Velocity.velocity = Player.Character.Torso.CFrame.lookVector*40
    fd = script.Firedamage:Clone()
    fd.Parent = x

 wait(5)
 x:remove()

wait(5)


end

function charging() --Charging function
	while charging == true do --Makes the part bigger while charging == true
		x.Size = Vector3.new(0.1,0.1,0.1)
		wait(0.1)
	end
end

game.Players.LocalPlayer.Mouse.Button1Up:connect(function() --Sets charging to false when you lift up your button
	charging  = false
end)

function onS(mouse) 
mouse.Button1Down:connect(function() onButton1Down(mouse) end) 
end 
bin.Selected:connect(onS)

1 comment

0

It doesn't work fully. It doesn't make the part increase in size and it prints errors. I added the bool value like i was supposed to.

This discussion is preserved as it was. New answers, comments, and votes are closed.