Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm looking to find the Player while being inside a global script & mouse function?

Asked by
Hizar7 102
6 years ago
Edited by Shawnyg 6 years ago

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)

01local Players = game:GetService("Players")
02 local block = game.Workspace.Part
03 local hitz = game.Workspace.Part.hits.Value
04local hitzn = game.Workspace.Part.hitn.Value
05local spawntime = 5
06local tool = script.Parent
07tool.CanBeDropped = false
08local stats = localPlayer.leaderstats
09local Iron = stats.Doubloons.Value
10tool.Equipped:Connect(function(mouse)
11    mouse.Button1Down:Connect(function()
12        if mouse.Target == block then
13                hitz = hitz + 1
14            if hitz >= hitzn then
15                hitz = 0
View all 27 lines...
0
Edit: Put code in a code block Shawnyg 4330 — 6y
0
Thanks Shawn! Would you happen to know the answer I am looking for ? Hizar7 102 — 6y
0
You can only get the mouse of a player in a local script. Now you'd have to work around that to be able values globally (assuming this is FE) . Read up on Remote Events / Remote Functions (Don't really need a rf for this) Shawnyg 4330 — 6y

Answer this question