When the player touches the ball, it creates Number Value. What I want it to do is when the player touches ball, the number value will keep on growing to a bigger number. I also what it to stop in 2 ways. 1 if it reaches to 200, it stops counting. 2 when somebody else touches the ball, it stops counting the person number who previously touched it. I try to do the number the loop but I did not under stand what i did.
local BallTarget = game.Workspace.BallTarget
local PlayersName = game.Workspace.BallTarget.BillboardGui.PlayersName
BallTarget.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and
game.Players:GetPlayerFromCharacter(hit.Parent) then
PlayersName.Text = hit.Parent.Name
BallTarget.Material = ("Neon")
BallTarget.BrickColor = hit.Parent:FindFirstChild("Torso").BrickColor
numvalue.Value = 0
while true do
number = numvalue.Value + 1
print(number)
wait(1)
end
end
end)
function BallTargethit(otherPart)
if otherPart ~= nil and otherPart.Parent ~= nil and otherPart.Parent:FindFirstChild("Humanoid") then
print("A player hit me!")
if not BallTarget:FindFirstChild(otherPart.Parent.Name) then
local playerTag = Instance.new("NumberValue")
playerTag.Parent = BallTarget
playerTag.Name = otherPart.Parent.Name
end
end
end
numvalue.Value = 0
while true do
number = numvalue.Value + 1
Value = (number)
wait(1)
end
BallTarget.Touched:connect(BallTargethit)

1 comment
Well to start, what you would want to do with the loop is make it it's own script and have it cloned to the NumberValue. Next thing you can do is while numvalue.Value > 200 do, this basically means that while the Value is under 200 it will continue going.