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

I'm trying to make a keybind script that is timed, it keeps failing. What is wrong with it?

I am trying to make a script that has 2 keybinds. 1 starts a timer that in this time slot the other can be pressed. I have it in a local script.

local player = script.Parent.Parent.Parent
local char = player.Character
local torso = char.Torso
local going = false
local timer = 0
local deb = false
local mouse = player:GetMouse()
function normaltorotate()
	torso.CFrame = torso.CFrame *CFrame.Angles(0,1,0)
	going = true
	print('rotated')
	torso.Anchored = true
end
function pulsedet()
	print('detonation')
	torso.Anchored = false
end
mouse.KeyDown:connect(function(rotate, pulse)
	if rotate == 'f' and not deb then
		deb = true
		normaltorotate()
		while going do
			if pulse == 'g' and going then
				pulsedet()
			end
			timer = timer+1
			if timer >= 5 then
				timer = 0
				beb = false
				torso.Anchored = false
				going = false
			end
			wait(.5)
		end
	end
end)

1 answer

KeyDown only returns a single argument, meaning 'pulse' is always going to be nil.

3 comments

0

so the keydown would have to be in the loop?

0

got it :D thx

0

What?

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