I want to make it so if you are not the creators you cant see the GUI, I created a script but it does not work. They are mutiple creators working on the game and I want to store the userids in a table.
There is nothing in output, it just wont work.
I have tried a module script, it did not work though.
local creatorsID =
{
{}, {}, {4124017097}
}
if game.Players.LocalPlayer.UserId ~= creatorsID then
script.Parent:Destroy()
return
end
local creatorsID =
{
{}, {}, {4124017097}
}
if table.find(creatorsID, game.Players.LocalPlayer.UserId) do
print("Owner")
else
script.Parent:Destroy()
end
You were comparing a user’s id to the whole table instead of looking for the userid in the table.
It’s important to understand that this only works because lua uses one based indexing. If this was another language, the first (0 index) creator wouldn’t be recognized with this same code.
[JS returns -1 if nothing is found in the equivalent function to fix this issue]
I can see there was having problem previous table in first. post. is it fixed? i already tested before
local creatorsID ={
0,
0,
4124017097
}
print(creatorsID)
if table.find(creatorsID,game.Players.LocalPlayer.UserId) then
print("Owner")
else
script.Parent:Destroy()
end
local Module=require(game.ReplicatedStorage:WaitForChild('Module',9))
print(Module.CreatorId)
if table.find(Module.CreatorId,game.Players.LocalPlayer.UserId) then
print("Owner")
else
script:Destroy()
end
You shouldn’t make it like this because it could get hacked easily. Instead, you should do something like this.
SERVER script in ServerScriptService
local ownerId = 1111111111
game.Players.PlayerAdded:Connect(function(player)
if player.UserId == ownerId then
Gui:Clone().Parent = player.PlayerGui
end
end)
Serverside it’s actually yea more secure there small different. i dont think if hacker having very fast to modify before got deleted
Serverside ( module still same )
local Module=require(game.ReplicatedStorage:WaitForChild('Module',9))
print(Module.CreatorId)
game.Players.PlayerAdded:Connect(function(player)
if table.find(Module.CreatorId,player.UserId) then
print("Owner")
end end)
It wasn’t specifically for you, but many people that do game development on Roblox will eventually move on to other platforms or other languages. Or maybe they came from another platform or use another language.
This is unnecessary and in a well made and thought-out game, exploiters should only be able to see the UI but not abuse the functions behind it. If you have a kick event that isn’t secured its a matter of time before someone kicks everyone and ruins your game.
If you want only certain userIds to see a gui, dont do it this way because if they find a way to disable the script before it has ran they can see it.
Instead place the GUI inside a script into server script service that checks everytime when a player joins if it’s in the user IDs table, then clone the GUI into the PlayerGui