Hello all! Sorry for the weird posting time(it’s 12:35 as I’m writing this), but I have a specific problem with a lot of moving parts. I attempted to make a script that, as the player killed NPCs, tracked the value of an IntValue. As said IntValue get higher, it edits the value of a StringValue in the leaderstats folder. I know this is a really weird system but I’d like to see a fix.
Here’s the system that triggers the increase in the IntValue.
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
local tag = hum:FindFirstChild("creator")
if tag then
local ePlayer = tag.Value
ePlayer.gloryCountFolder.glory.Value +=1
end
end)
Here’s the script that check for the IntValue. I get a strange error upon testing my game: “ServerScriptService.gloryMod:6: attempt to index string with ‘Parent’ - Server - gloryMod:6”. When I kill an NPC with the previous script in it, I get this one: " gloryCountFolder is not a valid member of Player “Players.ParkCityUSA” - Server - Script:7".
local Players = game:GetService("Players")
local function makeValueFolder(player)
local gloryCount = Instance.new("Folder")
gloryCount = "gloryCountFolder"
gloryCount.Parent = player
local intvalGlory = Instance.new("IntValue")
intvalGlory.Name = "glory"
intvalGlory.Parent = gloryCount
intvalGlory.Value = 0
if intvalGlory.Value >=1 then
local leaderstats = player:WaitForChild("leaderstats")
leaderstats:WaitForChild("Glory").Value = "Loser"
end
end
Players.PlayerAdded:Connect(makeValueFolder)
And lastly, here’s the leaderboard. I don’t think there are any problems with the code.
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local hacksilver = Instance.new("IntValue")
hacksilver.Name = "Hack-Silver"
hacksilver.Value = 0
hacksilver.Parent = leaderstats
local glory = Instance.new("StringValue")
glory.Name = "Glory"
glory.Value = "N/A"
glory.Parent = leaderstats
end
Players.PlayerAdded:Connect(leaderboardSetup)
I’d be really thankful if any of you could give me an idea on what’s going on, or even suggest a different system for this task. I really appreciate you taking the time out of your day to read this!
Thanks
PikeEnthusiast