So I have a code that goes like this:
game.ReplicatedStorage.HEADINCREASESTAT.OnServerEvent:Connect(function(player)
Size.Value = Size.Value + game.StarterGui.UI.BOOK.Value
end)
Size is a leader stat value and what am doing there is changing its value every time a player clicks, this works but it adds to everyone’s size in the server and I would like it to be added to whoever clicked.
How would I do this?
Thanks.
1 Like
Try
game.ReplicatedStorage.HEADINCREASESTAT.OnServerEvent:Connect(function(player)
Size.Value = Size.Value + player.PlayerGui.UI.BOOK.Value
end)
Also you shouldn’t add player points through a remote event because it can be abused easily
2 Likes
Nope still changes everyones values when clicking
1 Like
What do you mean everyones values
1 Like
When I click everyones Size changes and I want it to be that it changes to the person that clicked it
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:19pm
#6
game:GetService("ReplicatedStorage").HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value = player.leaderstats.Size.Value + player.PlayerGui.UI.BOOK.Value
end)
This should work. You are referencing size
as the value for all people.
1 Like
That works but it multiplies the value by the number of players,am thinking of diving the amount of the players to fix that
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:26pm
#8
What do you mean multiplying? How much is it multiplying it by?
Edit: try this:
game:GetService("ReplicatedStorage").HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value = player.PlayerGui.UI.BOOK.Value
end)
1 Like
It multiplies it by the number of players,I tried that but it just worked once then stopped working.
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:28pm
#10
What is the value you are entering?
1 Like
What do you mean?
Which value?
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:30pm
#12
The book value. The one that the script is setting the leaderstat to be.
1 Like
Its a “book” thing that i added,it basically increases how much size you get per click.
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:32pm
#14
Ohh, so is the book value always going up, or do you want to add the current value to the book value?
1 Like
The book value will go up if a player upgrades it,I just want to add the book value to the size everytime he clickes
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:34pm
#16
Ahhhh, ok I understand now. You want something like this:
game:GetService("ReplicatedStorage").HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value = player.leaderstats.Size.Value + player.PlayerGui.UI.BOOK.Value
end)
Make sure the book value is not 0 at the beginning!
1 Like
That works but it would add to the size how much people are in the server,so for example if there are 3 people in the server it will add to the size 3 times as much
1 Like
game:GetService("ReplicatedStorage").HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value = player.leaderstats.Size.Value + (player.PlayerGui.UI.BOOK.Value * #game.Players:GetPlayers())
end)
1 Like
Ethanoj1
(Ethanoj1)
September 9, 2020, 6:38pm
#19
Oh, really? Then you could do:
game:GetService("ReplicatedStorage").HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value = player.leaderstats.Size.Value + (player.PlayerGui.UI.BOOK.Value / #game:GetService("Players"):GetPlayers())
end)
1 Like
RAYTRAClNG
(RAYTRAClNG)
September 9, 2020, 6:39pm
#20
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
ReplicatedStorage.HEADINCREASESTAT.OnServerEvent:Connect(function(player)
player.leaderstats.Size.Value += (player.PlayerGui.UI.BOOK.Value * #Players:GetPlayers())
end)
This should do it. Also, I don’t think you can access PlayerGui on the server.
1 Like