local ReplicatedStorage = game:GetService("ReplicatedStorage")
local petCall = ReplicatedStorage:WaitForChild("PetCall")
local UIS = game:GetService("UserInputService")
local debounce = false
local cooldown = 51
UIS.InputBegan:Connect(function(input, istyping)
if istyping then
return
else if input.KeyCode == Enum.KeyCode.StarterGui.GetPet.then
if debounce == false then
debounce = true
petCall:FireServer()
wait(cooldown)
debounce = false
end
end
end
end)
What are you trying to do here? That’s not how you get a keycode Enum nor that is how you make an elseif statement
i want for mobile user. not for just PC user
You have to use ContextActionService, specifically BindAction if you want to also make it work for mobile users, or this may not be needed if there’s already code for when you press on that GetPet thing you’re trying to get, if so, just set Enum.KeyCode to a key you want and just make code for when you press on GetPet
Use BindAction if there’s no code in GetPet, else if there is just set keycode to whatever you want
i want a Script, if you touch GetPet (StaeterGui) it will give a pet. i try BindAction and i’ll alert you if it worked
Wait if you want it to do something when you touch GetPet, can’t you just use MouseButton1Click
on GetPet?
Try a localscript like this in the GetPet Object
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local petCall = ReplicatedStorage:WaitForChild("PetCall")
local UIS = game:GetService("UserInputService")
local debounce = false
local cooldown = 51
local GetPet = script.Parent
GetPet.MouseButton1Click:Connect(function()
if debounce then return end
debounce = true
petCall:FireServer()
wait(cooldown)
debounce = false
end)
OMG thanks a lot!!! it worked
Anytime! If you have anymore issues don’t be afraid to make another post! Also, just incase you’ll ask, this will also work on mobile as well