Here's a question, can I perform operations with number of values returned by a table? My thought is to make a simple voting system that checks the number of votes against the number of players until it reaches a 2/3 majority. For some reason though this checking script causes the entire place to lock up when it runs. I think it's to do with dividing by the #pls number.
function update(child)
local votes = script:WaitForChild("Votes").Value
if child.Name == "Votes" then return
else
votes = votes + 1
end
local pls = game.Players:GetChildren() -- pt. 2 of the problem
if (votes / #pls) > 0.6 then -- I think this line is the problem
local new = game.ServerStorage.Ball:Clone()
if game.Workspace:FindFirstChild("Ball") then
game.Workspace.Ball:Destroy()
end
new.Parent = game.Workspace
new.Position = Vector3.new(-49, 17.4, 27.034)
script:ClearAllChildren()
wait()
local vt = Instance.new("IntValue")
vt.Name = "Votes"
vt.Parent = script
end
end
script.ChildAdded:connect(update)

2 comments
Why is it a child added event?
Oh thanks, because the Vote Caster script creates a Value named after the player, which is parented then to the script. It was the easiest way I could think of this evening.