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

Getting a value from the player help?

I have this script that teleport people to a block and I have made a seperate script that puts a boolvalue into the character and can be turned on or off with a gui, How would I check to see if the boolvalue is true or false?

_G.StartingPlaces = {"StartingPlaceOne","StartingPlaceTwo","StartingPlaceThree","StartingPlaceFour","StartingPlaceFive","StartingPlaceSix"}
for LoadGlobalTable = 1,#_G.StartingPlaces do
	print(_G.StartingPlaces[LoadGlobalTable].."Loaded")
end
while true do
	for timewait = 25, 0, -1 do
		wait(1)
		game.Workspace.Timer.SurfaceGui.Time.Text = timewait
	end
game.Workspace.Timer.SurfaceGui.Time.Text = "Time"
--
s = game.Workspace.Spawns
p = game.Players:GetChildren()

for PlayerTeleport = 1, #p do --Where it teleports, so where it needs to decide if the value is true or not
if game.Workspace:FindFirstChild(p[PlayerTeleport].Name) then 
p[PlayerTeleport].Character.Torso.CFrame = s[_G.StartingPlaces[math.random(1,#_G.StartingPlaces)]].CFrame * CFrame.new(0,8,0)
end
script.Parent.NumberOfPeopleInGame.Value = #p
script.Parent.PeopleInGame.SurfaceGui.PeopleInGame.Text = "People in game:"..#p
end
end

1 answer

You can easily do so with an if statement.

if p[PlayerTeleport.Name].bool.Value==true then
--whatever here
end

You could also not write ==true because by default if statements check booleans

if p[PlayerTeleport.Name].bool.Value==true then
--whatever here
end

If you want it to check when its false, you could use "else" or do:

if p[PlayerTeleport.Name].bool.Value==false then
--whatever here
end

or

if not p[PlayerTeleport.Name].bool.Value then
--whatever here
end

Hopethis helped.

3 comments

0

I see, But it errored and said it tried to access "PlayerTeleport" a number value

0

Replace PlayerTeleport with whatever you need, I only put that because I saw it in your script.

0

well I think that'd be correct cause I need to replicate it across everyone in the server hence "PlayerTeleport" is "i =" in a for loop

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