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

Help? Value Changed function. Includes cframing to objects.

Any idea why this will not work?

local players = game:GetService("Players")
local spawnParts = workspace:WaitForChild("SpawnPs")
local spawns = spawnParts:GetChildren()

game.workspace.GameStats.GameRunning.Changed:Connect(function()
    if (game.Workspace.GameStats.GameRunning == true) then
        for _, player in next, players:GetPlayers() do
            local torso = player.Character and player.Character:FindFirstChild("Torso")
            if torso then
                local randomCF = spawns[math.random(#spawns)].CFrame
                torso.CFrame = randomCF
            end
        end
    end
end)

Any help is appreciated!

2 answers

✓ Accepted answer

I assume GameRunning is a BoolValue object. If that's the case, then on line 6, you have GameRunning == true. You should make it be GameRunning.Value == true. Remember that GameRunning is not true or false, its an instance of BoolValue.

game.Workspace.GameStats.GameRunning == true should be game.Workspace.GameStats.GameRunning.Value == true

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