Problem with pressing a button(mobile) (dash)


wait()

local player = game.Players.LocalPlayer
local character = player.Character

local UIS = game:GetService("UserInputService")
local ts = game:GetService("TweenService")

local remote = game.ReplicatedStorage.DashRemote
local FX = game.ReplicatedStorage.Fx
local animation = game.ReplicatedStorage.Animations 

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace.Map}

local debounce = false

local currentStamina = game.StarterPlayer.StarterCharacterScripts["StaminaRegen "].CurrentStamina
local maxStamina = game.StarterPlayer.StarterCharacterScripts["StaminaRegen "].MaxStamina
local neededStamina = 10


local data = game.Players.LocalPlayer:WaitForChild("Data")
local stamina = data:WaitForChild("Stamina")
local maxStamina = data:WaitForChild("MaxStamina")


local button = script.Parent

local function Tap()
	UIS.InputBegan:Connect(function(input, gpe)
		if gpe then return end
		
		--if not debounce then
			print("3")
			if stamina.Value >= 10 then
				debounce = true
				local anim
				local v = Instance.new("BodyVelocity", character.HumanoidRootPart)
				v.MaxForce = Vector3.new(999999, 0 , 999999)
				if UIS:IsKeyDown(Enum.KeyCode.Q) or character.Humanoid.MoveDirection.Magnitude == 0 then
					anim = animation.Dash
					v.Velocity = character.HumanoidRootPart.CFrame.LookVector * 80
				end

				character.Humanoid.Animator:LoadAnimation(anim):Play()
				game.Debris:AddItem(v, .3)
				remote:FireServer(character, v.Velocity, neededStamina, player)
				wait(0.6) -- cooldown
				debounce = false
			end

		--end
	end)
end

button.TouchTap:Connect(Tap)



remote.OnClientEvent:Connect(function(data)
	if data.Action == "Dash" then
		local hrp = data.Character.HumanoidRootPart

		for i = 1, 20 do
			for i = 1, math.random(1, 3) do
				local hb = FX.Sphere:Clone()
				hb.Parent = workspace.Fx
				hb.Anchored = true
				hb.CanCollide = false
				hb.Transparency = 0
				hb.Name = "hb"
				hb.Material = Enum.Material.Neon
				hb.CanQuery = false
				hb.Size = Vector3.new(.07, .07, math.random(4, 6))
				local colorRand = math.random(1, 3)
				if colorRand == 1 then
					hb.Color = Color3.fromRGB(0, 0, 0)
				else
					hb.Color = Color3.fromRGB(180, 180, 180)
				end
				hb.CFrame = CFrame.new(hrp.Position, hrp.Position + data.Direction) * CFrame.new(math.random(-25, 25)/10, math.random(-4, 2), math.random(-2, 2))
				game.Debris:AddItem(hb, .4)
				ts:Create(hb, TweenInfo.new(.4), {Transparency = 1, Size = Vector3.zero, CFrame = hb.CFrame * CFrame.new(0, 0, math.random(2, 4))}):Play()
			end

			local ray = workspace:Raycast(hrp.Position, Vector3.new(0, -4, 0), params)
			--if ray then
			--	local dust = FX.Dust:Clone()
			--	dust.Parent = workspace.Fx
			--	dust.CFrame = hrp.CFrame
			--	dust.Position = ray.Position
			--	dust.Attachment.Dust.Color = ColorSequence.new(ColorSequenceKeypoint.new(0, ray.Instance.Color), ColorSequenceKeypoint.new(1, ray.Instance.Color))
			--	dust.Attachment.Dust:Emit(10)
			--	game.Debris:AddItem(dust, 2)
			--end
			task.wait()
		end
	end
end)

Okay, the problem is that the ability itself works, but when you click on the button nothing happens, but when you click on the other part of the screen everything works, what is the problem?

1 Like

In the tap function, remove this part:

I think that should work

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.