Issue with mobile ability button

I can give you a code example of what is happening in the server script:

local event = game:GetService("ReplicatedStorage"):WaitForChild("AbilityEvent")

event.OnServerEvent:Connect(function(player, glove)
	local char = player.Character
	
	if glove.Value == "Default" then -- Default Glove
		local hum = char:FindFirstChild("Humanoid")

		local SFX = game.ServerStorage.Glove_Sounds.CoilSound:Clone()
		SFX.Parent = char:FindFirstChild("Head")
		SFX:Play()

		hum.WalkSpeed = 30
		wait(2)
		hum.WalkSpeed = 16		
		SFX:Destroy()
	elseif glove.Value == "Flop" then -- Flop Glove
		local Ragdoll = require(game.ServerScriptService.Player.Ragdoll.Main.Ragdoll)
		local Knockback = require(game.ServerScriptService.Player.Ragdoll.Main.KnockbackExtra)

		Ragdoll.Ragdoll(char)
		Knockback.Start(char:FindFirstChild("Flop"):FindFirstChild("Hitbox"):FindFirstChild("Root"), 75, 0.2, char:WaitForChild("HumanoidRootPart"))	
		wait(2)
		Ragdoll.UnRagdoll(char)
	elseif glove.Value == "Bloxxer" then -- Bloxxer Glove
		local RobloxLogo = game.ServerStorage.Glove_Objects.Logo
		local clonedLogo = RobloxLogo:Clone()

		clonedLogo.Parent = game.Workspace.Glove_Objects
		clonedLogo.CFrame = char:FindFirstChild("HumanoidRootPart").CFrame
		clonedLogo.Anchored = true

		task.wait(7)
		clonedLogo:Destroy()		
	elseif glove.Value == "YEET" then -- YEET Glove
		local Ragdoll = require(game.ServerScriptService.Player.Ragdoll.Main.Ragdoll)
		local KnockbackExtra = require(game.ServerScriptService.Player.Ragdoll.Main.KnockbackExtra)

		local Humanoid = char:WaitForChild("Humanoid")
		local Mscript = script.Parent.Parent
		local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")

		local Objects = game.ServerStorage.Glove_Objects.RandomThrowItems
		local Object = Objects:GetChildren()[math.random(#Objects:GetChildren())]:Clone()

		Object.Parent = game.Workspace.Glove_Objects
		Object.CFrame = HumanoidRootPart.CFrame
		Object.Position = HumanoidRootPart.Position

		local Speed = 120
		local Force = 80000
		local TotalForce = Force
		local KnockBack = Instance.new("BodyVelocity", Object)
		KnockBack.Parent = Object
		KnockBack.MaxForce = Vector3.new(2.5,0.60,2.5) * math.huge
		KnockBack.Velocity = HumanoidRootPart.CFrame.LookVector * Speed -- based on the direction YOUR character is facing.
		game.Debris:AddItem(KnockBack, 0.35)

		local SFX = game.ServerStorage.Glove_Sounds.YEET:Clone()
		SFX.Parent = char:FindFirstChild("Head")
		SFX:Play()

		Object.Touched:Connect(function(hit)
			if hit.Parent == char then 
				return 
			end

			if hit.Parent:FindFirstChildOfClass("Humanoid") then
				local plrChar = char

				Ragdoll.Ragdoll(hit.Parent)
				KnockbackExtra.Start(Object, 75, 0.2, hit.Parent:WaitForChild("HumanoidRootPart"))	
				wait(2.45)
				Ragdoll.UnRagdoll(hit.Parent)
			end
		end)

		wait(4)
		Object:Destroy()
		SFX:Destroy()	
	elseif glove.Value == "Knockball" then -- YEET Glove
		local Ragdoll = require(game.ServerScriptService.Player.Ragdoll.Main.Ragdoll)
		local KnockbackExtra = require(game.ServerScriptService.Player.Ragdoll.Main.KnockbackExtra)
		
		local Hum = char:WaitForChild("Humanoid")
		local HRP = char:WaitForChild("HumanoidRootPart")
		local Knockball = game:GetService("ServerStorage").Glove_Objects.KnockBallBall:Clone()
		local DebrisService = game:GetService("Debris")

		Knockball.Parent = workspace
		Knockball.CFrame = HRP.CFrame
		Knockball.Orientation += Vector3.new(-90,0,0)
		Knockball.Name = char.Name
		local BV = Instance.new("BodyVelocity", Knockball)

		BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		BV.Velocity = HRP.CFrame.LookVector * 150
		Knockball.Touched:Connect(function(hit)
			if hit.Parent == char then Knockball.CanCollide = false wait(0.2) Knockball.CanCollide = true return end

			if hit.Parent:FindFirstChildOfClass("Humanoid") then
				Ragdoll.Ragdoll(hit.Parent)
				KnockbackExtra.Start(Knockball, 50, 0.2, hit.Parent:WaitForChild("HumanoidRootPart"))	
				wait(2.45)
				Ragdoll.UnRagdoll(hit.Parent)
			end
		end)						
		wait(6)
		Knockball:Destroy()
	elseif glove.Value == "Podger" then -- Podger Glove
		local Hum = char:WaitForChild("Humanoid")
		local HRP = char:WaitForChild("HumanoidRootPart")
		local ClonedBomb = game:GetService("ServerStorage").Glove_Objects.Bomb:Clone()
		
		local timesBomb = char:FindFirstChild("CurrentBombs") or nil
		if timesBomb == nil then
			timesBomb = Instance.new("IntValue", char)
			timesBomb.Parent = char
			timesBomb.Value = 0 
			timesBomb.Name = "BombsLayed"
		end

		local function bombAction(b)
			local ticksound = Instance.new("Sound", b)
			ticksound.SoundId = "rbxasset://sounds\\clickfast.wav"
			local sound = Instance.new("Sound", b)
			sound.SoundId = "rbxassetid://5801257793"
			-- change the material of "b" to
			-- neon and change the colour to red
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()
			wait(1)
			b.Material = Enum.Material.Metal
			b.Color = Color3.fromRGB(255, 255, 255)
			wait(0.9)
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()
			wait(0.8)
			b.Material = Enum.Material.Metal
			b.Color = Color3.fromRGB(255, 255, 255)
			wait(0.7)
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()
			wait(0.6)
			b.Material = Enum.Material.Metal
			b.Color = Color3.fromRGB(255, 255, 255)
			wait(0.5)
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()
			wait(0.4)
			b.Material = Enum.Material.Metal
			b.Color = Color3.fromRGB(255, 255, 255)
			wait(0.3)
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()
			wait(0.2)
			b.Material = Enum.Material.Metal
			b.Color = Color3.fromRGB(255, 255, 255)
			wait(0.1)
			b.Material = Enum.Material.Neon
			b.Color = Color3.fromRGB(255, 0, 0)
			ticksound:Play()

			wait(0.2)
			sound:Play()
			
			local ClonedShockwave = game:GetService("ServerStorage").Glove_Objects.Shockwave:Clone()
			local DebrisService = game:GetService("Debris")

			ClonedShockwave.Parent = workspace
			ClonedShockwave.CFrame = b.CFrame
			ClonedShockwave.Anchored = true

			local ownerValue = Instance.new("StringValue")
			ownerValue.Value = char.Name
			ownerValue.Name = "Owner"
			ownerValue.Parent = ClonedShockwave

			-- make the cloned shockwave sphere object increase in size over time
			local TweenService = game:GetService("TweenService")
			local TweenInformation = TweenInfo.new(0.1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)

			local Goal = {Size = Vector3.new(25,25,25)}
			local Tween = TweenService:Create(ClonedShockwave,TweenInformation,Goal)
			Tween:Play()
			
			wait(0.25)
			b:Destroy()
			
			
			wait(0.6)
			for i = 1, 5 do
				ClonedShockwave.Transparency = ClonedShockwave.Transparency + 0.1
			end
			wait(0.5)
			ClonedShockwave:Destroy()	
		end

		ClonedBomb.Parent = workspace
		ClonedBomb.Position = HRP.Position
		bombAction(ClonedBomb)
		
		timesBomb.Value += 1
		if timesBomb.Value >= 10 then
			timesBomb = 0
			
			local badgeService = game:GetService("BadgeService")
			local BadgeId = 1771131057136880
			local PlayerId = player.UserId
			
			if not badgeService:UserHasBadgeAsync(PlayerId,BadgeId) then
				badgeService:AwardBadge(PlayerId,BadgeId)
			end
		end

		wait(20)
		ClonedBomb:Destroy()
	elseif glove.Value == "Coiner" then -- Coiner Glove
		local Objects = game.ServerStorage.Glove_Objects
		local CoinObject = Objects:FindFirstChild("Coin")
		local CoinCloned = CoinObject:Clone()
		
		if not char:FindFirstChild("AddedPower") then
			local AddedPower = Instance.new("IntValue")
			AddedPower.Parent = char
			AddedPower.Name = "AddedPower"
			AddedPower.Value = 1
		else
			local AddedPower = char:FindFirstChild("AddedPower")
			AddedPower.Value = AddedPower.Value + 1
		end
		
		local Sounds = game.ServerStorage.Glove_Sounds
		local CoinSound = Sounds:FindFirstChild("CoinSound")
		local CoinSoundCloned = CoinSound:Clone()
		CoinSoundCloned.Parent = char:FindFirstChild("Head")
		CoinSoundCloned:Play()
		
		CoinCloned.Parent = game.Workspace.Glove_Objects
		CoinCloned.Transparency = 0
		CoinCloned.Position = char:FindFirstChild("HumanoidRootPart").Position
		
		for index = 1,10 do
			CoinCloned.CFrame = CFrame.new(0,CoinCloned.CFrame.Y+1,0)
			CoinCloned.Transparency = CoinCloned.Transparency + 1*index
			wait(0.15)
		end
		
		task.wait(2.5)
		CoinCloned:Destroy()
	elseif glove.Value == "Anvil" then -- Anvil Glove
		local Ragdoll = require(game.ServerScriptService.Player.Ragdoll.Main.RagdollV2)
		local KnockbackExtra = require(game.ServerScriptService.Player.Ragdoll.Main.KnockbackExtra)

		local Hum = char:WaitForChild("Humanoid")
		local HRP = char:WaitForChild("HumanoidRootPart")
		local DebrisService = game:GetService("Debris")
		
		local function spawnAnvil()
			local Objects = game.ServerStorage.Glove_Objects
			local Anvil = Objects:FindFirstChild("Anvil")
			local AnvilCloned = Anvil:Clone()

			local Sounds = game.ServerStorage.Glove_Sounds
			local CoinSound = Sounds:FindFirstChild("CoinSound")
			local CoinSoundCloned = CoinSound:Clone()

			AnvilCloned.Parent = game.Workspace.Glove_Objects
			AnvilCloned.Transparency = 0
			AnvilCloned.Position = Vector3.new(HRP.Position.x + math.random(-25,25), HRP.Position.y + math.random(45,65), HRP.Position.z + math.random(-25,25))
			AnvilCloned.Anchored = false

			AnvilCloned.Touched:Connect(function(hit)
				if hit.Parent == char then return end

				if hit.Parent:FindFirstChildOfClass("Humanoid") then
					CoinSoundCloned.Parent = hit.Parent:FindFirstChild("Head")
					CoinSoundCloned:Play()

					Ragdoll.Ragdoll(hit.Parent)
					KnockbackExtra.Start(AnvilCloned, 70, 0.2, hit.Parent:WaitForChild("HumanoidRootPart"))	
					wait(3.5)
					hit.Parent:FindFirstChildOfClass("Humanoid").WalkSpeed = 16
					Ragdoll.UnRagdoll(hit.Parent)
					CoinSoundCloned:Destroy()
				end
			end)

			game.Debris:AddItem(AnvilCloned, 5)
		end
		
		local function rainAnvils()
			local index = 0
			local max = 10
			
			while wait(0.35) do
				if index >= max then
					break
				end
				
				spawnAnvil()
				index += 1
			end
		end
		
		rainAnvils()
	elseif glove.Value == "Medic" then -- Medic Glove
		local Hum = char:WaitForChild("Humanoid")
		
		if Hum.Health <= 85 then
			Hum.Health = Hum.Health + math.random(10,15)
		end
		
		local storage = game.ServerStorage
		local effect = storage.Glove_Objects.Hearts
		local clonedEffect = effect:Clone()
		
		clonedEffect = char:FindFirstChild("Head")
		game:GetService("Debris"):AddItem(clonedEffect,0.1)
	elseif glove.Value == "Aauugghh" then -- Aauugghh Glove
		local function shockwave()
			local ClonedShockwave = game:GetService("ServerStorage").Glove_Objects.Shockwave:Clone()
			ClonedShockwave.Color = Color3.new(1, 1, 1)
			ClonedShockwave.Transparency = 0.65
			local DebrisService = game:GetService("Debris")

			local ServerStorage = game.ServerStorage
			local Aaauggghhh = ServerStorage.Glove_Sounds.Aaauggghhh:Clone()
			Aaauggghhh.Parent = char:FindFirstChild("Head")
			Aaauggghhh:Play()

			ClonedShockwave.Parent = workspace
			ClonedShockwave.CFrame = char:FindFirstChild("HumanoidRootPart").CFrame
			ClonedShockwave.Anchored = true
			ClonedShockwave.Transparency = 0

			local ownerValue = Instance.new("StringValue")
			ownerValue.Value = char.Name
			ownerValue.Name = "Owner"
			ownerValue.Parent = ClonedShockwave

			-- make the cloned shockwave sphere object increase in size over time
			local TweenService = game:GetService("TweenService")
			local TweenInformation = TweenInfo.new(0.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In)

			local Goal = {Size = Vector3.new(25,25,25)}
			local Tween = TweenService:Create(ClonedShockwave,TweenInformation,Goal)

			local transparency = ClonedShockwave.Transparency
			local current = 0
			Tween:Play()

			wait(0.35)
			ClonedShockwave:Destroy()	
			wait(1)
			Aaauggghhh:Destroy()
		end
		
		char:FindFirstChild("Humanoid").WalkSpeed = 0
		shockwave()
		wait(1)
		char:FindFirstChild("Humanoid").WalkSpeed = 16
	elseif glove.Value == "Ducky" then -- Ducky Glove

		local function spawnDucky()
			local Duckies = {"MallardDucky", "NormalDucky", "PekinDucky"}
			local DuckyClone = game.ServerStorage.Glove_Objects.Duckies[Duckies[math.random(#Duckies)]]:Clone()	
			DuckyClone.Parent = game.Workspace.Glove_Objects		

			DuckyClone.Owner.Value = char.Name
			local HandleCFrame = char:FindFirstChild("Ducky"):FindFirstChild("Handle").CFrame
			DuckyClone:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(HandleCFrame.x + math.random(-3,3), HandleCFrame.y, HandleCFrame.z + math.random(-3,3))

			game.Debris:AddItem(DuckyClone, 15)
		end
		local function spawnEvilDucky()
			local DuckyClone = game.ServerStorage.Glove_Objects.EvilDucky:Clone()
			DuckyClone.Parent = game.Workspace.Glove_Objects		

			DuckyClone.Owner.Value = char.Name
			local HandleCFrame = char:FindFirstChild("Ducky"):FindFirstChild("Handle").CFrame
			DuckyClone:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(HandleCFrame.x + math.random(-3,3), HandleCFrame.y, HandleCFrame.z + math.random(-3,3))

			game.Debris:AddItem(DuckyClone, 20)
		end
		
		if math.random(1,200) == 1 then
			for i = 1, math.random(1,4) do
				local CharPlayer = game.Players:GetPlayerFromCharacter(char)
				-- award a badge with id 1817027293639161 to the player 
				-- if the player does not already have the badge.
				local badgeService = game:GetService("BadgeService")
				local BadgeID = 1817027293639161
				badgeService:AwardBadge(CharPlayer.UserId, BadgeID)
				spawnEvilDucky()
			end		
		else
			local CharPlayer = game.Players:GetPlayerFromCharacter(char)
			local badgeService = game:GetService("BadgeService")
			local BadgeID = 1817027293639161
			
			if badgeService:UserHasBadgeAsync(CharPlayer.UserId, BadgeID) then
				for i = 1, math.random(1,4) do
					spawnEvilDucky()
				end						
			else
				for i = 1, math.random(1,4) do
					spawnDucky()
				end		
			end
		end 
	elseif glove.Value == "noob" then -- noob Glove
		local Ragdoll = require(game.ServerScriptService.Player.Ragdoll.Main.Ragdoll)
		local OOOOOF = game.ServerStorage.Glove_Sounds.sounds.oof:Clone()
		
		OOOOOF.Parent = char:FindFirstChild("Head")
		OOOOOF:Play()
		
		char:FindFirstChild("Humanoid").RequiresNeck = false
		for index,joint in pairs(char:GetDescendants()) do
			if joint:IsA("Motor6D") then
				joint.Enabled = false
			elseif joint:IsA("BasePart") then
				joint.CanCollide = true
			end
		end
		wait(3.35)
	
		for index,joint in pairs(char:GetDescendants()) do
			if joint:IsA("Motor6D") then
				joint.Enabled = true
			end
		end
		char:FindFirstChild("Humanoid").RequiresNeck = true	
		OOOOOF:Destroy()
	end
end) 

Sorry if it is too big.

Okay the only thing i can think of is how you have the if statements with stuff like “knockball” and you arent firing anything of the sort from the local script. For example if the ability is knock ball shouldnt it be something like:

event:FireServer(“Knockball”)

This might be wrong, but its my best guess. Sorry if i couldnt help much

Where do you see event:FireServer("Knockball")?

Also, could we go back to the TouchTapScript?
Alright so, I keep looking here:

local abilityButton = script.Parent
local buttonText = script.Parent.Text
local label = playerGui:WaitForChild("AbilityGui").TextButton.CooldownLabel

abilityButton.MouseButton1Click:Connect(function()
	print("Mobile ability button pressed.")

Would it have something to do with the mousebutton1click?

I meant is that what its supposed to be? Because, i might be wrong, i thought that if you have an if statement like you do in the server script you have to be firing something from the local script. I hope that makes sense.

So, when you have

if glove == “knockball” then

On the server script should the local script have

event:FireServer(“Knockball”) or maybe its supposed to be event:FireServer(glove, “Knockball”)

So, when you have if glove == “knockball” then On the server script should the local script have event:FireServer(“Knockball”) or maybe its supposed to be event:FireServer(glove, “Knockball")

What I am firing from the localscript is the glove value and the player character: event.OnServerEvent:Connect(function(player, glove)
The If statements CHECK which glove the character has equipped so the ability can fire.

What I am trying to figure out is why it is not firing. My main suspect of the local script for mobile players!

Okay, my bad. I misunderstood.

Anyways, im really not sure why this one particulary ability isnt working for you. Im sorry and i wish i couldve helped more but yeah, im stumped too

Does mousebutton1click only work for computer clients or mobile clients or maybe both?

It should work for both. At least, ive alway used mousebutton1click and then playtested on mobile and its worked.

Would it be possible for at least 1 of you to help me in studios? I can take visual help, but I think I might start needing physical/real time help.

No i cant, sorry. I wish i couldve helped more but it really is weird to me why its not working unless i just really missed something

Probably read the whole thing again?
I mean, the WHOLE thing?

1 Like

Okay, i noticed that you define local player in a way that i think wont work

It should be game.Players.LocalPlayer

To my knowledge, and once i again i may be wrong, but i believe you have to have that

game.Players not just Players.LocalPlayer

I am doing this:

local Players = game:GetService("Players")
local player = Players.LocalPlayer  -- this only works in a LocalScript

Getting the players service, and getting …
wait.

This is a localscript. I can just go game.Players.LocalPlayer-
Thank you- Lemme test that.

1 Like

Alright, let me know if it happens to work. I wont be able to be online anymore but i hope i helped somewhat and wish i couldve helped more. I am kind of stumped though and maybe somebody smarter than me could help better.

It didn’t work, and yet every solution everybody has given be hasn’t worked. How do I fix this, and would the solution be!?

So, it’s been 21 hours since last post. Anybody still willing to help?

I don’t see any problem in your code, but if you claim that MouseButton1Click event doesn’t fire, then it might be because the button’s Interactable property is disabled. Check that again.

The property is enabled, it still isn’t firing.