Local Script Not Running Automatically

Hello Devs!
I am absolutely confused on why my localscript doesn’t execute automatically. The original location of the localscript was in ServerStorage (The reason for ServerStorage instead of a shared/client container is because of exploiters, and I don’t want any actions or messing with them). A Script in ServerScriptService Clones the Entire Folder with the scripts and changes the parent to the Player and other respected Containers (RS, SSS, WS, etc.).
I don’t receive any print statements, and I can confirm that the script doesn’t run when moved. I even tried doing the Enabled property on the script but sadly it never worked. I immediately turn on enabled when the localscript was moved to the Player Directly.
Here is the Explorer of the Folder:
image
Local Script (ClientHandler):

--//Services and Player
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local PS = game:GetService("Players")

local Player = PS.LocalPlayer
local Mouse = Player:GetMouse()

print("HELLO")
--//Remotes
local TeleportRemote = RS.DimensionsReplication:WaitForChild("Teleportation Dimension").Teleport

--//Functions and Connections
function TeleportConnection(Input, GameProcessed)
	if Mouse.Target == nil then warn("Nothing Found, Error Teleporting") return end
	local Position = Mouse.Hit.Position
	local EndStatus = TeleportRemote:InvokeServer(Position)
	warn(EndStatus)
end

UIS.InputBegan:Connect(function(Input, GameProcessed)
	if GameProcessed then print("False Activation.") return end
	if Input.KeyCode == Enum.KeyCode.F then
		TeleportConnection()
	end
end)

Server script sniplet moving the scripts:

--Player and Character Directly
	local DimensionPlayer = PhysicalDimensionEquiped.DimensionPlayer
	DimensionPlayer.Name = DimensionEquipedTable[1]
	DimensionPlayer.Parent = Player
	
	
	local DimensionCharacter = PhysicalDimensionEquiped.DimensionCharacter
	DimensionCharacter.Name = DimensionEquipedTable[1]
	DimensionCharacter.Parent = Character

Both Server Scripts work when moved, and remote is fully transported. The “ClientHandler” is the only problem.
Thanks for the help

3 Likes

The issue could be because on the client, ServerStorage doesn’t exist, meaning it can’t detect when it is moved to a different location. Try either putting the folder in another place, or just moving the script to another place, and hopefully it should work again.

2 Likes

But at the same time not all clients are supposed to receive this script, and I’m concerned as these are scripts which can be altered by exploiters.
This is why I didn’t put it inside StarterPlayer or StarterGui.
What containers should I put it in for max security as well as in one package with all scripts and etc.?

2 Likes

Honestly, any logic/data that could be exploited by the client should be in server scripts or module scripts that are only accessible to the server (i.e., in ServerStorage). You should assume the client is always untrustworthy and can modify whatever you send to it

3 Likes

It might be tough to do what you want it client-side. If you really want max security, I recommend trying to do it on the server, rather than on the client in my opinion. Assuming your LocalScript holds information you don’t want exploitable, it seems counter-intuitive to use a LocalScript in that case.

(You can scrap the idea about moving the folder if you were wondering)

3 Likes

So what if I can just keep the keybind there on a starterplayerscript and then fire the server when firing, but the logic is all handled by the server.
btw do localscripts inside guis cloned from ServerStorage also don’t execute?

2 Likes

That sounds fine.

It depends where you parent the guis with the LocalScripts. According to the documentation, LocalScripts will only run when they are in following containers:

  • StarterPack
  • StarterGui
  • StarterPlayerScripts
  • StarterCharacterScripts
  • ReplicatedFirst

Edit: Because everything in StarterGui is typically cloned to PlayerGui when the player character spawns, I assume LocalScripts will also run if you parent them directly to the player’s PlayerGui container.

2 Likes

So the localscripts are inside the GUI, and the gui already goes to the PlayerGui, I’m wondering if the same problem with the other client scripts will happen if the localscript is inside a client gui.

1 Like

It’s fine if the LocalScripts are inside a GUI. As long as the uppermost parent is one of those listed containers (including PlayerGui), the scripts should run.

2 Likes

And same thing applies to scripts and local scripts going to the Character?

1 Like

Right, because scripts inside StarterCharacterScripts get cloned automatically to the player’s character when it spawns.

I’d recommend placing scripts there if possible. It sounds like you’re doing manually what Roblox does for you automatically.

2 Likes

Ok then thanks!
If I do come across some more problems, I would reply here or shoot a DM
Thanks to you and @J_Angry for helping me!

3 Likes