I'm pretty new to lua coding and I do not know any function or something that can detect if something is a local script?
We can use the built-in Roblox function, :IsA, which basically outputs true or false if the ClassName of the part/script matches or doesn't match the ClassName we want. Since LocalScripts have a ClassName of 'LocalScript', all localscripts will output a true value when using :IsA("LocalScript")
For example,
localscript = script print(script:IsA("LocalScript"))
Outputs "true", whereas using
gui = script.Parent print(gui:IsA("LocalScript"))
Outputs false.
You can read more about ClassNames here: https://developer.roblox.com/en-us/api-reference/property/Instance/ClassName
And the :IsA function here: herehttps://developer.roblox.com/en-us/api-reference/function/Instance/IsA
Hopfully that helps.
Roblox has a simple in-build function to check if an instance is a given class:
if item:IsA("LocalScript") then print("This is a LocalScript") end