Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm Confused... Help me ?

I am confused over 2 topics, one is regarding LocalScripts and the other is regarding or in if's.

the only difference I know about a LocalScript is that not every service can be used in LocalScripts (Player Points as an example), also, we can use LocalPlayer in LocalScripts. But I have a small confusion. Would it make a huge difference if I put this code (below) in the Workspace instead of StarterPack:?

game.Players.PlayerAdded:connect(function (p)
	print ("Hi there, "..game.Players.LocalPlayer.Name.."! Welcome to _______"
end)

First confusion over

Next, I have the following script:

permission = {"fahmisack123","A380Guy","ismailtheboss"} 

texture = "www.roblox.com/Gem-Tycoon-VIP-Admin-shirt-item?id=129892951" 
texture2 = 157283455
function checkOkToLetIn(name) 
	for i = 1,#permission do 
		-- Convert Strings To All Upper Case, Otherwise We Will Let In 
		-- An Example Would Be "Username"
		if (string.upper(name) == string.upper(permission[i])) then return true end 
	end 
	return false 
end 

local Door = script.Parent

function onTouched(hit) 
	print("Door Hit") 
	local human = hit.Parent:findFirstChild("Humanoid")
	if (human ~= nil ) then 
		if human.Parent.Torso.roblox.Texture == texture or game:GetService("GamePassService"):PlayerHasPass(hit, texture2) then -- Confusion Here
			Door.Transparency = 0.6 --This Means How See-Through The Door Is
			Door.CanCollide = false 
			wait(3) --This Is The Length In Seconds Of How Long The Door Stays Open
			Door.CanCollide = true 
			Door.Transparency = 0 --This Means The Door Is Solid And You Cannot See Through It 
			print("Human touched door") 
		elseif (checkOkToLetIn(human.Parent.Name)) then 
			print("Human passed test") 
			Door.Transparency = 0.7
			Door.CanCollide = false --This Means The Door Is Not CanCollide And You Can't Walk Through It
			wait(3) --This Means How Long The Door Stays Open In Seconds
			Door.CanCollide = true 
			Door.Transparency = 0 
		end 
	end 
end 

script.Parent.Touched:connect(onTouched)

In Line 20 (I think), I have an or. This means if the player has the GamePass, but not the shirt, the door will function and vice versa. but what if BOTH are to be true? Would the door still function?

1 answer

Script 1: I would put in workspace... as then its gobal.

script 2: It would function as its an OR. Example: If you are hungry OR Thirsy then you die

This discussion is preserved as it was. New answers, comments, and votes are closed.