Hi there! So in short today I have made an ability for my game. The ability is activated by pressing the key Z on the computer. However, I need help to make it suitable for mobile as well, by like clicking a button to activate it so that it would work on mobile and pc.
This is all the stuff in my game at the moment:
So, I simply have the model for like the ice shard and a RemoteEvent in RepStorage, a few scripts and values.
However, the only script that I need help with moble support is the LocalScript in StarterPack called IceSpikeRemoteToFire. This is the code in the script in IceSpikeRemoteToFire which is located in StarterPack shown in the above image:
wait(1)
--Services--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
--Variables--
local Remote = ReplicatedStorage:WaitForChild("IceRemote")
local Player = game.Players.LocalPlayer
local Character = Player.Character
--Settings--
local CoolDown = true
local Key = "Z"
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and CoolDown and Character then
CoolDown = false
Remote:FireServer()
wait(8)
CoolDown = true
end
end)
So in short to recap, my aim is to be able to make the script above be able to work for mobile as well as pc. So something like pressing a GUI button to activate on mobile and keeping the method of pressing a key to activate on pc. Yeah so like press a button to activate on mobile, press a key on the keyboard like the one in the script above for pc
Any help would be really appreciated! Thank you so much!!!