#how do i turn this into a keybind

1 messages · Page 1 of 1 (latest)

buoyant sorrel
#

local cd = 1

script.Parent.Activated:Connect(function()
if db == false then
db = true
script.Event:FireServer()
wait(.1)
wait(cd)
db = false
end
end)
into a keybind

oak hill
#

Use userinputservice

#

Ngl I forget the exact syntax so look at the docs

#

But userinputservice is the way to go

#

👍

fallen ermine
#

whats a syntax?

#

the parameter?

oak hill
#

The syntax is the way or writing it

rotund willow
#

user userinputservice.OnKeyPressed:Connect()

and then you can get the key, compare enum.key to the enum.key.yourkeybind

oak hill
#

Yea

rotund willow
#

at least thats what i think from memory

#

lol

oak hill
#

Yea my memory is bad for userinputservice

#

Did you figure it out?

buoyant sorrel
#

i dont know what u mean, i just started coiding'

#

Coding

fallen ermine
#

nobody writes script here

oak hill
#

Yea

fallen ermine
#

we just fix scripts

buoyant sorrel
#

oh

#

i just dont know what he means by

fallen ermine
#

u should learn it

buoyant sorrel
#

i just dind tknow how

fallen ermine
#

watch some videos about userinputservice

buoyant sorrel
#

i tried many ways

oak hill
#

Read documentation

fallen ermine
#

wdym u dont know how

buoyant sorrel
#

like

#

i tried many ways and i failed

fallen ermine
#

show me your ways

uncut terraceBOT
#

studio** You are now Level 21! **studio

fallen ermine
#

i'll tell u whats wrong

buoyant sorrel
#

i did this

#

if input.KeyCode == Enum.KeyCode.Z then
script.Event:FireServer()
if db == false then
db = true
wait(.1)
wait(cd)
db = false
end
end)

#

the red lines arent telling me anything'

uncut terraceBOT
#

studio** You are now Level 1! **studio

oak hill
#

Yea but it's gotta be in userinputservice

#

The key pressed event of it

buoyant sorrel
#

so would i put this in it or before it

#

user userinputservice.OnKeyPressed:Connect()

#

?

oak hill
#

Yea

buoyant sorrel
#

what did u delete

oak hill
#

In

#

But look at the parameters it takes

buoyant sorrel
#

how could i put it in

buoyant sorrel
bronze seal
#

wait did you give the script to know what the input is

buoyant sorrel
#

i gave the script cuz i wanna make it so it activates when the key is pressed while the tool is equipped

#

but im not working it out

fallen ermine
#

always start with

#

UserInputService.Inputbegan

rotund willow
#

you need to decalre uis

buoyant sorrel
# fallen ermine UserInputService.Inputbegan

so like this? UserInputService.Inputbegan.OnKeyPressed:Connect()
if input.KeyCode == Enum.KeyCode.Z then
script.Event:FireServer()
if db == false then
db = true
wait(.1)
wait(cd)
db = false
end
end)

bronze seal
#

character:Findfirstchild("TOOLNAME")? it will say when the tool is equipped because it connectes to the characters right @fallen ermine or am i wrong

buoyant sorrel
#

this is so confusing, watching tutorials and shi and still aint getting nothing

fallen ermine
#

not "events"

fallen ermine
#

It's the same for every service i think

#

you can only define 1 event

buoyant sorrel
#

well

#

im trying to do everything and it still doesnt work

#

im so confused

#

cuz right now

#

when the tool is clicked

#

it works

#

but i wanna turn that into a keybind

rotund willow
#

??

#

i feel like you skipped some things

buoyant sorrel
#

local db = false
local cd = 1

script.Parent.Activated:Connect(function()
if db == false then
db = true
script.Event:FireServer()
wait(.1)
wait(cd)
db = false
end
end)

#

this is the full script when clicked

#

but im tryna turn into when KEY is clicked, it activates the rest

#

thats what im having trouble with

buoyant sorrel
#

where would i find this for tools?

rotund willow
uncut terraceBOT
#

studio** You are now Level 2! **studio

rotund willow
#

tool.activated -> turns a variable true
tool.deactivated -> turns the variable false

pressing the key -> check if the variable is true, then run it

#

you need to do UIS, its ANY user keyboard input

buoyant sorrel
#

like

#

when press Z this skill used

rotund willow
#

oh ok

warped epoch
# buoyant sorrel its because im tryna make a one piece blox fruit type system

look bruh not trying to demotivate you but if you can't even handle userinputservice to capture a keypress, you sure as heck aint making no bloxfruit clone, far less even a generic battlegrounds game. yes i know how badly everyone wants one of their own, but it aint happening. sorry. you need to get better at coding first. don't start with your dream game. start with something simpler.

warped epoch