So I want to check if frame named “Copyright” exist, if does, it will kick the player instead.
Also, can I somehow require this script so they cannot edit it?
Code:
while true do
if script.Parent.Main.Copyright ~= "" then
for _,v in pairs (game.Players:GetChildren()) do
v:Kick("Stealing is prohibited... ~ Pirate's Ranking Service")
end
script.Parent:Destroy()
end
wait(30)
end
i think you should use FindFirstChild, if it finds a child it will return it else it will return nill.
I think this code will work:
while true do
if script.Parent.Main:FindFirstChild("Copyright") then
for _,v in pairs (game.Players:GetChildren()) do
v:Kick("Stealing is prohibited... ~ Pirate's Ranking Service")
end
script.Parent:Destroy()
end
wait(30)
end
No one can change a script’s source (Only plugins). Clients can view the source with some strange exploits. And what do you mean? Please explain more and a bit of grammar.
to require a module only in-game (Not studio) You need the function IsStudio to check if the script is running in Roblox Studio. To require a module only in Roblox studio you need this script:
if game:GetService("RunService"):IsStudio then
-- Do things
end
and if you want a script run only in the game you need this script:
if not game:GetService("RunService"):IsStudio then
-- Do things
end
If I’m correct you’d want to kick the player if they deleted the “Copyright” frame locally. This means you’d need to check the player every 30 seconds or so (depending on the interval you want) to see if they had the “Copyright” frame in their PlayerGUI. This script will only work on the server and will not work on the client (localscripts)
while true do
for i,player in pairs(game.Players:GetPlayers()) do
if player.PlayerGui.NAMEOFGUIHERE.Main:FindFirstChild("Copyright") ~= true then
player:Kick("whatever kick message you'd want here")
end
end
wait(30)
end
For assistance on learning to use ModuleScripts the best place to look is the Roblox Wiki or to open another support thread with this specific issue, please try and use community resources first though.
Yeah, if an instance doesn’t exist you have to use FindFirstChild. Trying to access it by indexing directly doesn’t work. This is why FindFirstChild is a thing.
@TheTurtleMaster_2 has the correct solution. (Please do note to use the capital W for Workspace or use the workspace global)
I do want to explain why things like this doesn’t work:
local part = workspace.Part
if part == nil then do
end
Your trying to define a Part in workspace as “part”. Instead of “part” being defined as nil, it gives you an error at that line when your defining that variable since it doesn’t exist.
FindFirstChild method is the best way to check if something exists. You should use FindFirstChild only when your not sure if something will exist at that time and you want to check. Also note that FindFirstChild is about 20% slower than using “.” to index something.