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

Make Dash Script Mobile friendly by creating button.?

So, I got this dash script, and it works all fine 'n' chill, but I want to make it mobile friendly by creating a button, which only appears on mobile devices, pls give me some pointers in the right direction, maybe some pages on the roblox wiki or something.. I am NOT requesting a whole script.. Here's My Script:

local player = game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAddeed:Wait()
local UIS = game:GetService("UserInputService")
local humanoid = player.Character.Humanoid

local debounce = false
local cooldown = 1 -- Time to wait between 2 dash

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id="--Insert ID here

UIS.InputBegan:Connect(function(input,IsTyping)
	if IsTyping then
		return
	elseif input.KeyCode == Enum.KeyCode.Q then
		if debounce == false then
				debounce = true
		local playAnim = humanoid:LoadAnimation(anim)
			playAnim:Play()
			local Character = game.Workspace:WaitForChild(player.Name)
			Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector*500
			local Trail1 = Instance.new("Trail",Character)
	Trail1.Attachment0 = Character.RightFoot:FindFirstChildOfClass("Attachment")
	Trail1.Attachment1 = Character.RightLowerLeg:FindFirstChildOfClass("Attachment")
	Trail1.Lifetime = 0.2
	Trail1.MaxLength = 1
	Trail1.WidthScale = NumberSequence.new(0.8)
	Trail1.FaceCamera = false
	local Trail2 = Instance.new("Trail",Character)
	Trail2.Attachment0 = Character.LeftFoot:FindFirstChildOfClass("Attachment")
	Trail2.Attachment1 = Character.LeftLowerLeg:FindFirstChildOfClass("Attachment")
	Trail2.Lifetime = 0.2
	Trail2.MaxLength = 0.5
	Trail2.WidthScale = NumberSequence.new(0.8)
	Trail2.FaceCamera = false
	local Trail3 = Instance.new("Trail",Character)
	Trail3.Attachment0 = Character.LeftLowerArm:FindFirstChildOfClass("Attachment")
	Trail3.Attachment1 = Character.LeftHand:FindFirstChildOfClass("Attachment")
	Trail3.Lifetime = 0.2
	Trail3.MaxLength = 0.5
	Trail3.WidthScale = NumberSequence.new(0.8)
	Trail3.FaceCamera = false
	local Trail4 = Instance.new("Trail",Character)
	Trail4.Attachment0 = Character.RightLowerArm:FindFirstChildOfClass("Attachment")
	Trail4.Attachment1 = Character.RightHand:FindFirstChildOfClass("Attachment")
	Trail4.Lifetime = 0.25
	Trail4.MaxLength = 0.5
	Trail4.WidthScale = NumberSequence.new(0.8)
	Trail4.FaceCamera = false
	local Trail5 = Instance.new("Trail",Character)
	Trail5.Attachment0 = Character.UpperTorso:FindFirstChildOfClass("Attachment")
	Trail5.Attachment1 = Character.LowerTorso:FindFirstChildOfClass("Attachment")
	Trail5.Lifetime = 0.25
	Trail5.MaxLength = 0.5
	Trail5.WidthScale = NumberSequence.new(0.8)
	Trail5.FaceCamera = false
	wait(.5)
	for i = 0,1, .1 do
		Trail1.Transparency = NumberSequence.new(i)
		Trail2.Transparency = NumberSequence.new(i)
		Trail3.Transparency = NumberSequence.new(i)
		Trail4.Transparency = NumberSequence.new(i)
		Trail5.Transparency = NumberSequence.new(i)
		wait()
	end
	Trail1:remove()
	Trail2:remove()
	Trail3:remove()
	Trail4:remove()
	Trail5:remove()
			wait(cooldown)
	debounce = false
		end
	end
end)


1 answer

✓ Accepted answer

I'm afraid you'll have to switch to ContextActionService and use the BindAction method, which allows you to automagically create or delete a button when binding or unbinding an action. Otherwise, you'll have to make your own mobile buttonhandler, which is two more events and much less fun.

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