I’m trying to make it so when I join/reset/refresh or get killed, I still have my GUI.
I’ve got this script to work and it gives me the controls but if I reset, get killed or refresh myself, I don’t have the GUI anymore.
I’ve looked through the Chat function but I haven’t found anything.
--Made By MillerrIAm
--------Variables-------
GUI = game:GetService("ServerStorage").ControlGui.Controls
local Admin = false
---------Admins--------
local admins = {"MillerrIAm","NemesisY2J","Sonicxman","Dewwy5280","JessChrist","AnarchyxRT"}
--------Main Code------
game.Players.PlayerAdded:Connect(function(plr)
for i,v in pairs (admins) do
if v == plr.Name then
Admin = true
end
end
if Admin then
GUI:Clone().Parent = plr.PlayerGui
else
print("Guest Entered")
end
end)
Use a CharacterAdded event. Code inside a function connected to this signal will run when the player respawns (recognised as a change to Player.Character).
I would disagree, no matter your local script parent or location any exploiter can access. Why? Well because it’s local. Right now you shouldn’t be too worried about security, I find when developing games over worrying about security can cause games to fail, what you should be doing is knowing what should be on the client and what should be on the server and focus on security after the game is complete. I would worry a bit more about performance personally but that’s just me
EDIT: If all the exploits are only client sided and is not messing with your game itself that breaks in game economy or something it’s fine.
My game is heavily based off of these controls, it’s not a typical roblox game. Someone that would be the controller/ host has to be there for the event to go on, otherwise there is no game hence why I have to be very careful with what I do.
Still doesn’t matter overall, If I were to exploit your game and couldn’t access your “controls” I would make my own because you technically can. The reason I know about this is because my friend owns a paid exploit program that injects new local scripts and that’s what most exploiters are, injecting new scripts and running new code. Once again as long as your controls are a LocalScript or a ModuleScript that is accessible by the client, there is no point in “hiding” them, the best you can do is make sure to add checks inside the client and server.
EDIT: You can’t really hide the script either, there is this UI made for exploiters called “Dark Dex” or “Dex Dark” basically a in game explorer tab that shows all the content in game that is visible to the client.
EDIT 2: I took a quick look and I see you are cloning the UI from ServerStorage, that’s still exploitable because the LocalScript that’s inside the UI is accessible as soon as you give it to the client, they can modify it and do any changes.
EDIT 3: If you really don’t trust me that’s fine, the other way would be to simply add a CharacterAdded listener like what @colbert2677 stated.
it doesn’t run through local scripts and where the control it self is at is secure. my controls are in a place clients can’t find nor see. Hence why I am having issues.
I mean my controls themselves are in a different spot then what you’d expect and I have local scripts inside but I’m slowly working to work around that and use typical scripts due to exploiters. Also, I am going to hope that there is a way to work around that like what i’ve been doing. With this, exploiters I deal with use that stuff and have stated they aren’t able to access my stuff with videos and such asking how I was controlling my event.
Honestly I doubt you will be able to work around it right now, but I have heard that Roblox is implementing UserInputService into the server (which I do not understand how) but currently I don’t think it’s possible.
Also if you meant that your controls are in ServerStorage. Then are duplicated into the client, players are still able to access that after being added. Players are also able to create their own controls.
This is not proper use of StarterCharacterScripts. The container is meant for code that your character will be utilising. You should not be using it as a workaround for code that’s irrelevant to the character because you don’t want to use CharacterAdded (which is the respawn-based signal).
They aren’t. Don’t spread rumours under the pretense that you “heard it”. If you don’t have a citation, better not to give false hope for a feature that will not make it to production and has no reason to either.
I’ve only heard and what he said only reminded me of a memory of it, that doesn’t mean that it’s true though. And controls are to be used by the player which will affect the character so I don’t see why you wouldn’t use StarterCharacterScripts as a place to put controls in.
Character controls don’t belong in StarterCharacterScripts; not even the default controls script is located there. StarterCharacterScripts is canonically intended for scripts that will affect the character. Currently, these are the Animate and Health scripts. The character sound script was also here until it was moved to support a better solution with less overhead and mess.
Furthermore, the word controls isn’t limited towards character controls. The context of controls here is a set of special map controls for a list of administrators (which is defined in the OP). It has no place in StarterCharacterScripts.
The simple answer, as I have already given it, is to wrap the code in a CharacterAdded event so that the Gui will add itself again when the character performs their first spawn or respawns.
yeah, about that… I’m entirely lost and I feel like it’s something simple and I’m getting more frustrated doing this… I figured you could find the issue here, I keep getting an error with my in pairs value says attempting to call a string value which I am doing but it wouldn’t let me check the name when I did plr:GetPlayers() which I have it run off the names to see if they’re an admin or not. I’m either over-thinking this or I’m missing something important. The script as of right now…
--Made By MillerrIAm
--------Variables-------
GUI = game:GetService("ServerStorage").ControlGui.Controls
local plr = game:GetService("Players")
local RunServ = game:GetService("RunService")
local Admin = false
---------Admins--------
local admins = {"MillerrIAm","NemesisY2J","Sonicxman","Dewwy5280","JessChrist","AnarchyxRT"}
--------Main Code------
local function AdminsAllowed(plr)
for i,v in pairs (plr.Name) do
if v.Name == admins then
GUI:Clone().Parent = plr.PlayerGui
else
print("Guest Entered")
end
end
end
local function PlayerArrived(player)
player.CharacterAdded:Connect(AdminsAllowed)
end
plr.PlayerAdded:Connect(PlayerArrived)
You should read your code again. You made only one slight mistake and that was swapping the variables in the for loop and the if statement under it.
local function AdminsAllowed(plr)
-- Use ipairs when it comes to arrays/lists
for _, v in ipairs(admins) do
-- Try to use UserIds instead of usernames for admin-like scripts
if plr.Name == v then
GUI:Clone().Parent = plr.PlayerGui
-- Don't need the loop running anymore
break
end
end
end
P.S. This code, as it is connected to CharacterAdded, will check the name of the character instead of the player. Not that it’s particularly any problem but in the future you may want to look into writing that code differently.
Okay so I having an issue that’s small but it says that PlayerGui isn’t a valid member of the model so I’m guessing it’s right now getting the Player Model and not the Player Asset, is there a way to fix this?