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

Help? Value Changed function. Includes cframing to objects.

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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.

Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
8 years ago

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

Answer this question