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

Why does E keypress function fire but not Q?

I have 2 functions one fired when Q is released and the other when E is released. Yet the E function only fires. Here is what i have:


function onQPress(actionName, userInputState, inputObject)
	if userInputState == Enum.UserInputState.End then
		model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(30),0))
	end
end
game.ContextActionService:BindAction(8, onQPress, true, "q")
		
		
		
		
function onEPress(actionName, userInputState, inputObject)
	if userInputState == Enum.UserInputState.End then
		model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(330),0))
	end
end
game.ContextActionService:BindAction(8, onEPress, true, "e")

There are no errors, it just doesn't work. I have even switched the code inside the If statement from the onEPress function with the code inside the If state of the onQPress function yet E is still the one that works.

1 answer

✓ Accepted answer

You use the same name for binding each action. BindAction has a name arg which can then be used to unbind that connected action meaning two of the same names cannot be used.

This name should also be a string, example:-

-- I would also recommend that you use the key code ie Enum.KeyCode instead of a string 
game.ContextActionService:BindAction('RoateModel1', onQPress, true, 'q')

game.ContextActionService:BindAction('RoateModel2', onEPress, true, 'e')

I hope this helps.

1 comment

0

Wow.... I checked and double checked the Description of the BindAction... I now see i was looking at the wrong place. lel Thanks!

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