Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script won’t work on mobile, but will work on roblox Mobile emulator, why would this happen?

Asked by 3 years ago

Hello, again! So I’ve been trying to make my game more mobile-friendly for its release, but it won’t work for mobile players but it will work on the Roblox Mobile emulator, even if I use my Pc’s touch screen, but I’m not sure why it won’t work on actual mobile devices. In this script, I use the UserInputService, TouchTap, but it won’t work with any touch events anyway. I did a simple test by creating a script that creates a part every time the player touches the screen and it works, so it must be a problem with my code. But even then, when I use the Roblox emulator this script works as it should, but it is not receiving inputs from mobile devices. Below I have left my script, it is a local script. And I have no errors when the event is fired and it all works perfectly, but not on mobile devices but it does work on the Roblox mobile emulator and touch screen of my laptop.

local players = game:GetService("Players")
local player = players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Mouse = player:GetMouse()
local PlayerStats = Character:FindFirstChild("PlayerStats")
local Magic = PlayerStats:WaitForChild("Magic")
local CurrentMagic = Magic.CurrentMagic 
local MaxMagic = Magic.MaxMagic
local FireCircleEvent = game.ReplicatedStorage.SpellEvents:WaitForChild("FireCircleSpell") 
local UIS = game:GetService("UserInputService")
local connect
local Debounce = true 



player.Chatted:Connect(function(msg)
    if string.lower(msg) == "phasmatos incendia circulum" and Debounce == true then 
        Debounce = false 

        connect = UIS.TouchTap:Connect(function(tp, GPE)
            if Mouse.Target.Parent:FindFirstChild("Humanoid") and CurrentMagic.Value >= 80 then 
                local Victim = Mouse.Target.Parent
                local Distance = (Character.HumanoidRootPart.Position - Victim.HumanoidRootPart.Position)

                if Distance <= 25 then 

                    Debounce = true 
                    FireCircleEvent:FireServer(Debounce, Victim, msg)
                    Debounce = false 
                    connect:Disconnect()
                    wait(5)
                    Debounce = true
                    -- (player, Debounce, victim, msg)
                end
            end
        end)
    end
end)

Answer this question