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

I am having trouble trying to implement a stringvalue. How can I fix this?

I made a secure gate for airlines that gives them the ability to change a screen containing the flight status, Flight number, Aircraft type. Not only that but it can control who can board through the card scanners. Everything is working but I have one issue. For example, when I press the first class button it is supposed to not only change the flight status on the SurfaceGui but also change who is able to get through the gate to board the plane. What I did is make the script change a stringvalue item and set the value to the Card name which in this case is First. Here is the code for the textbutton for First Class.

function onClicked()
script.Parent.Parent.ticket.Value = "First"
script.Parent.Parent.class.Text = "First Class"
script.Parent.Parent.Parent.Parent.Parent.Screen.Part.SurfaceGui.Frame.Frame.two.status.Text = "Boarding First Class"
end

script.Parent.MouseButton1Down:connect(onClicked)

These lines of code work when changing the screen text and the string value (which is named ticket) is indeed changing when I test this in-game. The problem is, I can't seem to find out how I can use the stringvalue in this script

permission = { "First";"Business";"Investor" }
Sensor = script.Parent
active = false

function checkOkToLetIn(name)
	for i = 1,#permission do
		
		if (string.upper(name) == string.upper(permission[i])) then return true end
	end
	return false
end

function onTouched(hit)
	print("Sensor Hit")
	local human = hit.Parent:findFirstChild("Humanoid")
	if (human ~= nil ) then
		print("Human touched door")
		if (checkOkToLetIn(human.Parent.Name)) and active == false then
			print("Human passed test")
			active = true
			script.Parent.Parent.Light.Decal.Texture = "http://www.roblox.com/asset/?id=147922702"
			script.Parent.Parent.Door.CanCollide = false
			for i=1, 45 do
				script.Parent.Parent.p1.CFrame = script.Parent.Parent.p1.CFrame*CFrame.Angles(0, math.rad(2), 0)
				script.Parent.Parent.p2.CFrame = script.Parent.Parent.p2.CFrame*CFrame.Angles(0, math.rad(-2), 0)
				wait()
			end
			wait(1)-- Open time
			script.Parent.Parent.Light.Decal.Texture = "http://www.roblox.com/asset/?id=147922941"
			for i=1, 45 do
				script.Parent.Parent.p1.CFrame = script.Parent.Parent.p1.CFrame*CFrame.Angles(0, math.rad(-2), 0)
				script.Parent.Parent.p2.CFrame = script.Parent.Parent.p2.CFrame*CFrame.Angles(0, math.rad(2), 0)
				wait()
			end
			script.Parent.Parent.Door.CanCollide = true
			active = false
		end
	end
end

Sensor.Touched:connect(onTouched)

Where it says permission = { "First";"Business";"Investor" }. I want to instead put in the string value. I've tried multiple times in different ways to put it in but when I click First Class and go to test the gate with the First card it does not work. Please help me! Thanks.

2 comments

0

I don't know if semicolons work, but commas are what most people use: permission = { "First","Business","Investor" }

0

No I want to put that stringvalue in to replace the card. Lets say the stringvalues value is First. It will then put in the name First and search for the card name First. I just want to control what card can be used in the gate.

1 answer

I would recommend changing your "checkOkToLetMeIn" function:

permission = --[[Access StringValue here. Do not access its .Text, just the StringValue itself.]]
function checkOkToLetMeIn(name)
	return string.upper(name) == string.upper(permission[i].Value)
end

Now, the function always checks the StringValue's text, rather than relying on constants in a table.

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