Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Getting a value from the player help?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

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

Log in to vote
1
Answered by
KoreanBBQ 301 Moderation Voter
8 years ago

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.

0
I see, But it errored and said it tried to access "PlayerTeleport" a number value NotSoNorm 777 — 8y
0
Replace PlayerTeleport with whatever you need, I only put that because I saw it in your script. KoreanBBQ 301 — 8y
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 NotSoNorm 777 — 8y
Ad

Answer this question