I am currently making a system that will help developers not get the products stolen. Without going into too much detail, I have made a script that sends a message via webhook to discord. Then inside that script, there is a localscript that contains the UI message using instance.new() and all that.
How would I make it so that you could move the local script to the player’s UI?
The main script called, “LeakProtection” is in workspace and the “leak” local script is a child of it.
I’ve already tried putting this in the local script but it didn’t work:
local gui = script
for i, v in pairs(game.Players:GetChildren()) do -- loops through all players in the server
local clone = gui:Clone()
clone.Parent = v.PlayerGui
end
Not many places. It would be easier to just parent the LocalScript to something like StarterPlayerScripts, then if you need to reference the LocalScript just do player.PlayerScripts.leak
So I just tried it and it works, though the point is to make a leak protection system simple so a developer can just insert it into their model and the script does all the work. Would that even be possible because the local script makes the GUI?
What do you mean, you can clone from local scripts. There is no correct way, you clone from a local script the same way you would a normal script. The reason his script won’t work is because:
What if I were to put the local script in the script under Workspace, and then have the script clone the localscript to StarterPlayerScripts and then have the local script run? Would that work?
Is a ServerScript (correct me if I’m wrong in that) but anyways, you can’t get “LocalPlayer” in server scripts, for your use case do this:
local Players = game:GetService("Players")
local function OnPlayerAdded(player)
local clone = script.leak:Clone()
clone = player.PlayerScripts
end
Players.PlayerAdded:Connect(OnPlayerAdded)
But either way
use WaitForChild as the PlayerScripts might not be loaded yet
local Players = game:GetService("Players")
local function OnPlayerAdded(player)
local clone = script.leak:Clone()
clone.Parent = player:WaitForChild("PlayerScripts")
end
Players.PlayerAdded:Connect(OnPlayerAdded)
local Players = game:GetService("Players")
local function OnPlayerAdded(player)
local clone = script.leak:Clone()
clone.Parent = player:WaitForChild("PlayerGui")
end
Players.PlayerAdded:Connect(OnPlayerAdded)