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

How to Make an Automatic Gun Using ROBLOX's RayCasting Script?

Guys, I am so sorry... this is such a simple question but I do not know. I think it has something to do with loops. I am not sure. I am using ROBLOX's RayCasting Script. I don't need a super long answer or anything, just something to point me in the right direction. Thank you! -TheFierceWaffle

1 answer

✓ Accepted answer

Well you can just do Button1Down etc like so

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local mouseDown = false
local canPlay = true

mouse.Button1Down:Connect(function()
	mouseDown = true
end)

mouse.Button1Up:Connect(function()
	mouseDown = false
end)

while true do

	if mouseDown then
		if canPlay then
			canPlay = false
			--Put your code stuff here
			canPlay = true
		end
	end
end

Hope it helped :D If it helped please mark it as answered

2 comments

0

no wait

0

what?

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