Comments (1)
I'm sorry, but I am not familiar with that game. As a starting point, you can detect User Input with UserInputService.InputBegan
, which returns an InputObject
. You can then check the KeyCode
property of the InputObject
to see if it matches any of the keys that the player would need to press in order to activate that ability / power / etc.
Here's a quick example:
local UserInputService = game:GetService("UserInputService")
local abilityKeyCodes = {
[1] = Enum.KeyCode.One,
[2] = Enum.KeyCode.Two,
[3] = Enum.KeyCode.Three
}
local function activateAbility(number)
-- There are other ways of implementing this, but this might be more intuitive to understand, to start
if number == 1 then
-- Run code related to the ability that should be activated with the "1" key
elseif number == 2 then
-- Run code related to the ability that should be activated with the "2" key
elseif number == 3 then
-- Run code related to the ability that should be activated with the "3" key
end
end
UserInputService.InputBegan:Connect(function(inputObject, interactedWithUI)
if interactedWithUI == true then return end
local keyCode = inputObject.KeyCode
local abilityCheck = table.find(abilityKeyCodes, keyCode)
if abilityCheck then
activateAbility(abilityCheck)
end
end)
For future reference, this isn't the correct category for these kinds of questions. The "Issues" section of this repository is meant for highlighting issues with the code, models, etc. of my tutorials that have been posted here. If you have a suggestion for a future tutorial, you can post that in the Discussions category / section.
However, the question you asked here might be better suited for the Roblox Developer Forum. There are probably some existing threads on the Developer Forum where people have asked similar questions that were eventually solved, which might be able to help with answering your question(s) much faster than I'd be able to, especially since I don't know much about the game that you referenced.
from roblox-studio-tutorials.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roblox-studio-tutorials.