Hello. I am trying to make my guns mobile-friendly and I want the players to have shiftlock while aiming with the guns. I found this (ex: 1) service that does that for you, but I dont need this for PC, so how can I delete the module scripts via a local script?
there are also ways to detect if a client is on a certain device so you could disregard this entirely and write a function that detects which device the client is on, but i am not the person to ask and im 100% certain that there are other posts on this topic if you need help
you should only have to do it for the scripts that are required for the shiftlock. since they are module scripts, you could also find the script that is requiring the module scripts and first have it check if the client is on the right device then have it require the scripts, which either one works best for you
remove module scripts via a local script in Roblox, you can iterate through the descendants of the player’s character or a specific location in the game and remove the module scripts that you do not need. Here is an example of how you can achieve this:
local Players = game:GetService("Players")
local function removeModuleScripts()
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
for _, descendant in ipairs(character:GetDescendants()) do
if descendant:IsA("ModuleScript") then
descendant:Destroy()
end
end
end
-- Call the function to remove module scripts
removeModuleScripts()
This script gets the player’s character and iterates through all its descendants. If it finds a module script, it destroys it.
If you want to target a specific location instead of the character, you can change the character variable to point to that location. For example, if your module scripts are all under a specific folder in the game, you can adjust the script like this:
local specificFolder = game.Workspace.YourFolderName -- Change this to the path of your folder
local function removeModuleScriptsFromFolder(folder)
for _, descendant in ipairs(folder:GetDescendants()) do
if descendant:IsA("ModuleScript") then
descendant:Destroy()
end
end
end
-- Call the function to remove module scripts from the specific folder
removeModuleScriptsFromFolder(specificFolder)
Make sure to replace YourFolderName with the actual name of the folder you are targeting.
this would run as soon as the client loads right? the op is looking for this to fire if the client is on mobile so for this to be effective for their requests you would first have to determine if the client is on the right device right? ive only been scripting in luau for a couple months now so im just asking for clarification
Yes, you are correct. To ensure that the script only runs on a mobile client, you need to check the device type before executing the removal of module scripts. Roblox provides a way to determine the client’s device type using the UserInputService.
can you send a ss of the console? to determine if its only running on mobile, youll have to go to the “test” tab at the top of studio and click the “device” option, there you can select the dropdown and pick from a variety of mobile devices
first of all, it would be easier to enable the output directly in studio rather than opening the console within the test
it looks like error is running within your module scripts from before, im assuming since youre trying to mess with shiftlock that you copied and pasted the build in camera scripts, are you sure youve put these scripts in the right destination theyre supposed to be in?
im not too great with things like this but sending a ss of the code around line 469 in the CameraModule script could help
double check that the “PlayerModule” module script is parented under “StarterPlayer.StarterPlayerScripts”, as the script is looking for a boolean within the player instance, and is accessing it by calling the parent of the “PlayerModule” module script, so if its placed it the wrong spot, the script wont be able to find the player instance and will throw an error
Those are roblox scripts, the Player Controller and the Camera basically. I don’t know what he is trying to do, but messing with the PlayerModule like that is bound to cause issues. It is possible to fork the PlayerModule (which would probably be a better solution), though not recommended as you wont get the changes roblox make to it