Hello everyone,
So I am learning to script and the vidoe I am watching is talking about when you click a brick it will give u a point in the leader stats. I understand how it all works but getting a error. If anyone could help me that would be great.
First Script to create the leaderstats:
game.Players.PlayerAdded:Connect(function(plr)
local Leaderstats = Instance.new("Folder", plr)
Leaderstats.Name = "leaderstats"
local points = Instance.new("IntValue", Leaderstats)
points.Name = "Points"
points.Value = 100
end)
Second script to add on the points:
game.Workspace.Clickpoint.ClickDetector.MouseClick:Connect(function()
local leaderpoint = Players.leaderstats.Points
leaderpoint.Value = leaderpoint.value + 5
end)
1 Like
JayO_X
(fakefriends)
December 8, 2020, 10:14pm
#3
The leaderstats is right but the second script isnt
I suggest adding a player in the parameter function so you can get the leaderstats and then add cash like this.
game.Workspace.Clickpoint.ClickDetector.MouseClick:Connect(function(player)
local leaderstats = player.leaderstats
local points = leaderstats.Points
points.Value = points.Value + 1
end)
JayO_X
(fakefriends)
December 8, 2020, 10:15pm
#4
Where did you define the players in the second script that might be the problem
You should not be modifying leaderstats on the client.
stqrrydev
(stqrrydev)
December 8, 2020, 10:16pm
#6
That’s just the solution if you want that script to run without an error I believe
Why does it say on here then to?
VIDEO
1 Like
JayO_X
(fakefriends)
December 8, 2020, 10:18pm
#9
For the final script it should be
game.Players.PlayerAdded:Connect(function(plr)
local Leaderstats = Instance.new(“Folder”, plr)
Leaderstats.Name = “leaderstats”
local points = Instance.new("IntValue", Leaderstats)
points.Name = "Points"
points.Value = 100
end)
game.Workspace.Clickpoint.ClickDetector.MouseClick:Connect(function(player)
local leaderpoint = player.leaderstats.Points
leaderpoint.Value = leaderpoint.value + 5
end)
That is the exact thing I did??
Nothing will change on the server if you modify leaderstats on the client.
1 Like
JayO_X
(fakefriends)
December 8, 2020, 10:19pm
#12
you didn’t define the player in the script
game.Workspace.Clickpoint.ClickDetector.MouseClick:Connect(function(player) --gets the player who clicked it
stqrrydev
(stqrrydev)
December 8, 2020, 10:21pm
#13
Sorry about that. Ig I was trying to write a reply and didn’t notice that. Ill delete my post so nobody uses that lol
I’m definitely not a master at doing leaderstats and datasaves
Wow I am soo stupid. Thanks lol.
Deimesa
(Mesa)
December 9, 2020, 2:01am
#15
It’s also probably worth noting that you did not capitalize the second “Value.”
game.Workspace.Clickpoint.ClickDetector.MouseClick:Connect(function()
local leaderpoint = Players.leaderstats.Points
leaderpoint.Value = leaderpoint.**v**alue + 5
end)