I'm looking to find the Player while being inside a global script & mouse function?
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)
01 | local Players = game:GetService( "Players" ) |
02 | local block = game.Workspace.Part |
03 | local hitz = game.Workspace.Part.hits.Value |
04 | local hitzn = game.Workspace.Part.hitn.Value |
06 | local tool = script.Parent |
07 | tool.CanBeDropped = false |
08 | local stats = localPlayer.leaderstats |
09 | local Iron = stats.Doubloons.Value |
10 | tool.Equipped:Connect( function (mouse) |
11 | mouse.Button 1 Down:Connect( function () |
12 | if mouse.Target = = block then |
16 | mouse.Target.Transparency = 1 |
17 | mouse.Target.BrickColor = BrickColor.Black() |
18 | mouse.Target.CanCollide = false |
19 | game.Players.LocalPlayer.leaderstats.Iron.Value = game.Players.LocalPlayer.leaderstats.Iron.Value + 1 |
22 | block.CanCollide = true |
23 | block.BrickColor = BrickColor.Blue() |