I’m trying to make something fairly simple, so I feel like I’m just dumb for not getting it… It’s just a simple thing where you run into something to pick it up and it adds +1 to the leaderboard score. After everything I’ve seen, I feel like this should work, but it’s not :[
I have two separate scripts. One’s a normal script:
local LP = game:GetService("Players")
local pill = workspace:WaitForChild("pill")
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local vScore = Instance.new("IntValue")
vScore.Name = "Score"
vScore.Value = 0
vScore.Parent = leaderstats
leaderstats.Parent = player
end
for _, player in pairs(LP:GetPlayers()) do
onPlayerAdded(player)
end
LP.PlayerAdded:Connect(onPlayerAdded)
and then another that’s in a local script
local pill = workspace:WaitForChild("pill")
local function pillTouched(part)
pill.Transparency = 1
pill.CanCollide = false
game.Players.LocalPlayer.leaderstats.Score.Value=game.Players.LocalPlayer.leaderstats.Score.Value+1
end
pill.Touched:Connect(pillTouched)
I had it all in one script before, but then LocalPlayer can’t be in a normal script, and a local script doesn’t make the leaderboard, and now I’m at least not getting any errors but touching the block doesn’t do anything. Furthermore, I wanna add more blocks to pick up and I’m fairly certain there’s has to be a better way than making a million in the script lmao
I’d appreciate any help with this! Sorry if this seems like a dumb question, I couldn’t find anything that addressed this that seemed to actually help…