Hi, What I am trying to do is locate the player so that I can adjust the leaderboard values inside the global script, What i am going to show you works in a local script, but does not work in a global script because It wont find the player, I have tried to add a playeradded function but it does not work... please someone help! I am relatively new at scripting.. Please! What this script is doing is targeting a part in workspace that has values. once the parts value need is met, i would like to add the created value to the leaderstats. Currently this script is sitting inside the tool (I have to use a tool, no touch functions)
local Players = game:GetService("Players") local block = game.Workspace.Part local hitz = game.Workspace.Part.hits.Value local hitzn = game.Workspace.Part.hitn.Value local spawntime = 5 local tool = script.Parent tool.CanBeDropped = false local stats = localPlayer.leaderstats local Iron = stats.Doubloons.Value tool.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target == block then hitz = hitz + 1 if hitz >= hitzn then hitz = 0 mouse.Target.Transparency = 1 mouse.Target.BrickColor = BrickColor.Black() mouse.Target.CanCollide = false game.Players.LocalPlayer.leaderstats.Iron.Value = game.Players.LocalPlayer.leaderstats.Iron.Value +1 wait (spawntime) block.Transparency = 0 block.CanCollide = true block.BrickColor = BrickColor.Blue() end end end) end)