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

What is another version of game.Players.LocalPlayer for a regular Script?

Asked by
Vxpper 101
5 years ago

I'm wondering another way to access a LocalPlayer through a regular script, How would I go about doing this?

game.Players.LocalPlayer.MoneyValue

That's what I'm trying to do only through a Script, How would I accomplish this?

0
LocalPlayer is nil to the server and always will be. There are many ways to get the player from the server, such as ClickDetector.MouseClick User#19524 175 — 5y
0
im trying to load the value for my developer handler the other script i posted Vxpper 101 — 5y

2 answers

Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
5 years ago
Edited 5 years ago

There's no way of doing this with a script without having no input from the player. If you have an input from a player, such as MouseClick, Touched, etc., then you can find the "local player."

One way of doing this is acquiring the name of the player through the event and finding the player.

Example 1

script.Parent.Touched:Connect(function(characterBodyPart)
    local characterName = characterBodyPart.Parent.Name -- Gets the name of the player that touched the object.
    local player = game.Players:FindFirstChild(characterName) -- Finds the player with that name and indexes it as 'player'.
end)
0
Perfect! LinKiNSpitZ 22 — 5y
0
https://scriptinghelpers.org/questions/66506/issue-with-developer-products-why-is-it-doing-this This is why I am asking because that script is not working because i'm trying to add to a value that I'm adding through a LocalPlayer Vxpper 101 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You could also add a remote event in replicatedStorage and a local script in starterGui and call for the server from the individual player's client.

In Local Script

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("RemoteEvent")
local player = script.Parent.Parent

remote:FireServer(player)

In Server Script

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("RemoteEvent")

remote.OnServerEvent:connect(function(player)
     player.MoneyValue
end)

Hope this helps

0
If you look at my other post about developer products would this work with that script? Vxpper 101 — 5y
0
Yes it should BillyNoodles 9 — 5y

Answer this question