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?
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?
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)
Perfect!
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
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
If you look at my other post about developer products would this work with that script?
Yes it should
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
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
im trying to load the value for my developer handler the other script i posted