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

player adding and removing counter script not working please help me?

Asked by 3 years ago
game.Players.PlayerAdded:Connect(function()
    game.Workspace.Value.Value = game.Workspace.Value.Value + 1
end)

game.Players.PlayerRemoving:Connect(function()
    game.Workspace.Value.Value = game.Workspace.Value.Value - 1
end)

game.Workspace.Value.Value = game.StarterGui.ScreenGui.TextLabel.Text

it says that the last line isnt working ;(

1 answer

Log in to vote
0
Answered by 3 years ago

Well if the value is an IntValue type, you should do the following: I don't know what is your goal with this,so you may clarify it so i can help you better.

game.Players.PlayerAdded:Connect(function(Player) --When a player joins this event is fired,giving the parameter of the player who joined
    game.Workspace.Value.Value += 1 --You can use operator += to add to its value without copying the sentence again
        wait(3)
        game.Workspace.Value.Value = tonumber(Player:WaitForChild("PlayerGui").ScreenGui.TextLabel.Text) --Convert the number string to a number type,or else it will print an error!
end)

game.Players.PlayerRemoving:Connect(function()
    game.Workspace.Value.Value -= 1 --Same as up but is subtraction
end)

game.Workspace.Value.Value = tonumber(game..ScreenGui.TextLabel.Text) --Convert the number string to a number type,or else it will print an error!

If you want to change it , remember, you cant edit the startergui properties on the player,as it replicates to the player in a folder called PlayerGui.

Also the tonumber() function converts strings in numbers (Text property is a string type.) And WaitForChild waits for the child of a parent to load.

Hope it helps!

0
Dont paste the last two line yuni_Boy1234 320 — 3y
Ad

Answer this question