Roblox Studio is still thinking properties are physical items inside something

I’m starting to get really annoyed with this. It seems that scripts think properties are actual scripts, parts, physical items inside the workspace or inside the part. I have a script, and it uses game.Players.PlayerAdded but Studio keeps thinking PlayerAdded is a thing inside players, not a property. This is strange, as the script it’s in uses PlayerAdded twice. But it only happens with the one I typed out. The rest of the scripts, other than the problematic line, is completely fine. I’ll put the entire script below. The output states: 'PlayedAdded is not a valid member of Players “Players” - Server - Script:48. The rest of the script is completely functional, because it’s borrowed from another game I’m making. Why is Roblox doing this? I literally can’t script anything because apparently a property is actually a part inside a script. This has been annoying me to the point of where i’m thinking about quitting scripting. I can’t do it, so why should I? This has been going on for a really long time, I’d say maybe mid-2020. Please fix this, I can’t do anything.
–coins and data
local replicated = game:GetService(“ReplicatedStorage”)
local dataservice = game:GetService(“DataStoreService”)
local plrData = dataservice:GetDataStore(“plrData”) --changing “plrData” will make all players lose their data
game.Players.PlayerAdded:Connect(function(player)
local leader = Instance.new(“Folder”)
leader.Name = “leaderstats”
leader.Parent = player

local coin = Instance.new("IntValue")
coin.Name = "Coins"
coin.Parent = leader

local level = Instance.new("IntValue")
level.Name = "Seconds"
level.Parent = leader

local key = "player_"..player.UserId
local playerstats = plrData:GetAsync(key)
if playerstats then
	coin.Value = playerstats[coin.Name]
	level.Value = playerstats[level.Name]
else
	coin.Value = "100"
	level.Value = "0"
end

end)

local function datatable(player)
local data = {}
for _, stat in pairs(player.leaderstats:GetChildren()) do
data[stat.Name] = stat.Value
end
return data
end

game.Players.PlayerRemoving:Connect(function(player)
local data = datatable(player)
local yes, no = pcall(function()
local key = “player_”…player.UserId
plrData:SetAsync(key, data)
end)
if not yes then
warn(“Data not saving.”)
end
end)
– line
game.Players.PlayedAdded:Connect(function(player) --problematic line, giving error
player.Chatted:Connect(function(msg)
print(msg)
if msg == string.match(msg, “;”) then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 2
end
end)
end)

1 Like

Oh, I had this issue before when I used RunService and tried get heartbeat and it didn’t work even though it should be valid. Not sure what the exact fix is but I restarted studio a couple times and rewriting the code manually.

1 Like

There’s a typo. You wrote PlayedAdded instead of PlayerAdded.

2 Likes

To add on to what @Wicked_Wlzard said, even the output shows the typo. If you go back and change it to PlayerAdded instead of PlayedAdded, you should be fine.