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

Is there a "game.Players.LocalPlayer" for a regular script, or something similar?

Asked by 5 years ago

Is there a game.Players.LocalPlayer type thing for a regular script, or anything else I could do to access a Player without a localscript?

I'm trying to make a Miner's Haven type game, and I'm getting stuck on adding the ore's value to a cash value in the leaderboard. Here's my script.

(If needed, this is a regular script in a part in the workspace)

local sellValue = 100

script.Parent.Touched:Connect(function(Toucher)
    if Toucher:FindFirstChild("OreValue") then
        local OreValue = Toucher.OreValue
        print("The ore's value is " .. OreValue.Value)
        OreValue.Value = OreValue.Value * sellValue
        print("The ore was sold for " .. OreValue.Value)
        --??? How to add to leaderboard
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Kinda.

You can do:

game.Players.PlayerAdded:Connect(function(player)
    ...
end)

and inside that function "player" would be like LocalPlayer

1
that worked. Thanks! DaBrainlessOne 129 — 5y
Ad

Answer this question