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

Can i acess Local Player using a script? [FOR SURFACE GUI]

Asked by 5 years ago

I'm working with SurfaceGUIs and i have to use a script for the button function, and that means i'd need to find a way to acess a local player using a script.

SCRIPT:

repeat wait() until game.Players.LocalPlayer ~= nil

local Player = game:GetService("Players").LocalPlayer

--\PLAYER VALUES/--

local CORE = Player.PlayerGui:WaitForChild("Core")

local Values = CORE:WaitForChild("Values")

local PaymentValue = Values:WaitForChild("PaymentValue")
local PaymentTime = Values:WaitForChild("PaymentTime")
local Employeed = Values:WaitForChild("Employeed")

--\TABEL VALUES/--

local Tabel = script.Parent.Parent

local TabelValues = Tabel:WaitForChild("Values")


local ShiftTime = TabelValues:WaitForChild("ShiftTime")
local Payment = TabelValues:WaitForChild("Payment")


script.Parent.MouseButton1Down:Connect(function()
    if Employeed.Value == false then
        Employeed.Value = true
        PaymentTime = ShiftTime
        PaymentValue = Payment
    end
end)

I can explain the code in-case you wanna help.

0
You should handle button clicking using a local script and any stat you want to change in a server script. Use a remote event to communicate to the server for that. xPolarium 1388 — 5y
0
No, localplayer is never ever accessible through normal server scripts, only local scripts. LoganboyInCO 150 — 5y
0
how about keep trying script.Parent or script.Parent.Parent and printing til you find the player HappyTimIsHim 652 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Although you can't use LocalPlayer in server scripts, many events pass it as a parameter. For example, PlayerAdded's only parameter is the player who joined the game.

game:GetService("Players").PlayerAdded:Connect(function(player)
    print(player.Name)
end)
1
Thanks, i already solved it utrabem 5 — 5y
Ad

Answer this question