Look at this image, do you see anything wrong with it?
3, 2, 1…
Ok, Times up if you saw whats wrong with this or if you dont, then basically, NoobCoins is clearly a child of leaderstats. I dont know why the heck the coins are not adding into the leaderboard
Leaderstats
game.Players.PlayerAdded:connect(function(plr)
local f = Instance.new("Folder", plr)
f.Name = "leaderstats"
local NoobCoins = Instance.new("IntValue", f)
NoobCoins.Name = "NoobCoins"
NoobCoins.Value = 0
NoobCoins.Parent = game.ServerScriptService.leaderstats
end)
game.Players.PlayerAdded:connect(function(plr)
local f = Instance.new("Folder", plr)
f.Name = "leaderstats"
local PowerAmulet = Instance.new("IntValue", f)
PowerAmulet.Name = "PowerAmulets"
PowerAmulet.Value = 0
PowerAmulet.Parent = game.ServerScriptService.leaderstats
end)
Collect Script
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ServerScriptService.leaderstats.NoobCoins.Value = player.leaderstats.NoobCoins.Value + 1
wait(1)
script.Parent:Remove()
end
end
end)
Output
20:56:53.787 Super Oofy 64 @ 27 May 2021 20:56 auto-recovery file was created - Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
20:57:08.351 LocalPlayer is not a valid member of Workspace "Workspace" - Client - DeathAnimation:1
20:57:08.351 Stack Begin - Studio
20:57:08.351 Script 'Workspace.NubblyFry.DeathAnimation', Line 1 - Studio - DeathAnimation:1
20:57:08.351 Stack End - Studio
20:57:19.477 0.5, 0.5 - Server
20:57:19.841 0.5, 0.5 - Client
20:59:25.474 NoobCoins is not a valid member of Folder "Players.NubblyFry.leaderstats" - Server - CollectScript:8
20:59:25.475 Stack Begin - Studio
20:59:25.475 Script 'Workspace.Noob Coin.CollectScript', Line 8 - Studio - CollectScript:8
20:59:25.475 Stack End - Studio
21:07:02.175 Disconnect from ::ffff:127.0.0.1|57243 - Studio
The problem is that when the player joins and the NoobCoins (IntValue) is created, you set it to the ServerScriptService, removing it from the player. Then in your collect script, you’re trying to set the value of the NoobCoins instance(in ServerScriptService) to the value of the value of a non-existent NoobCoins Instance which you’re looking for in the player … (the one you moved to ServerScriptService when the player joined)…
08:25:56.465 Super Oofy 64 @ 28 May 2021 08:25 auto-recovery file was created - Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
08:26:03.848 LocalPlayer is not a valid member of Workspace "Workspace" - Client - DeathAnimation:1
08:26:03.849 Stack Begin - Studio
08:26:03.849 Script 'Workspace.NubblyFry.DeathAnimation', Line 1 - Studio - DeathAnimation:1
08:26:03.850 Stack End - Studio
08:26:08.714 Workspace.FallDamageScript:17: attempt to perform arithmetic (sub) on nil and number - Server - FallDamageScript:17
08:26:08.715 Stack Begin - Studio
08:26:08.715 Script 'Workspace.FallDamageScript', Line 17 - Studio - FallDamageScript:17
08:26:08.715 Stack End - Studio
08:26:10.937 0.5, 0.5 - Server
08:26:11.393 0.5, 0.5 - Client
08:26:12.189 noobCoins is not a valid member of Script "ServerScriptService.leaderstats" - Server - CollectScript:8
08:26:12.190 Stack Begin - Studio
08:26:12.190 Script 'Workspace.Noob Coin.CollectScript', Line 8 - Studio - CollectScript:8
08:26:12.190 Stack End - Studio
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ServerScriptService.leaderstats.noobCoins.Value = player.leaderstats.noobCoins.Value + 1
wait(1)
script.Parent:Remove()
end
end
end)
Thats what I changed, and I also changed the leaderstats
Why are you making “Coins” Value parent of a folder and after of a ServerScriptService.leaderstats? It won’t work because every leaderstats value need to be a descendant of player.
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.NoobCoins.Value = player.leaderstats.NoobCoins.Value + 1
wait(1)
script.Parent:Remove()
end
end
end)
Please watch some YouTube tutorials on leaderstats, they are very helpful.