(This is filtering enabled)
The title is vague, but let me explain:
I want this code to run when a value in the replicatedStorage has changed:
game.Players.PlayerAdded:connect(function(plr)
if game.ReplicatedStorage.keepTrackOfVariablesPlease.Value == true then
wait()
for i = 0, #game.Players:GetChildren(), 1 do
x = i
end --counting
warn("Counting")
if x >= 1 then
print(x)
game.ReplicatedStorage.ValidPlayerCounter:Fire()
warn("Game can start now!")
game.ReplicatedStorage.validPlayerCount.Value = true
game.ReplicatedStorage.canStart.Value = true
else
print(x)
game.ReplicatedStorage.nonValidPlayerCount:Fire()
game.ReplicatedStorage.validPlayerCount.Value = false
end
game.ReplicatedStorage.gameStarted.Changed:connect(function()
if game.ReplicatedStorage.keepTrackOfVariablesPlease.Value == true then
if game.ReplicatedStorage.canStart.Value == true then
local chosen = math.random(1, table.getn(spawners))
local picked = spawners[chosen]
plr.Character.UpperTorso.CFrame = CFrame.new(workspace.Teleports:FindFirstChild(picked).Position + Vector3.new(0,3,0))
game.ReplicatedStorage.stopOn.Value = true
for i,v in pairs(game.Players:GetChildren()) do
if v:FindFirstChildWhichIsA("Player") then
local thread = Instance.new("BoolValue")
thread.Parent = game.Players.Alive
thread.Name = plr.Name
end
end
end
end
end)
end
end)
The thing is; that the only way I can get this to work is to put it in the "onPlayerAdded" function, which makes it only run once. I want this to run multiple times, so I was wondering what function I'd put it in and how to get that value of the player?

2 comments
Sorry, I guess I was a little too vague. I need it to teleport the person when this happens, but since this game is FE, I have to do it through a script, yet I don't know how I can get the player's character.
Nevermind, I found out how to do it.