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

How to get a player from them pressing a textbox on surfacegui?

Asked by 7 years ago
Part=script.Parent.Parent.Parent.Parent.Parent.Parent
Pa=Part.PA
Pb=Part.PB
Pc=Part.PC
enabled=true
Multiplier=10 --Charles if you want to change the outcome of the credits just change this variable
script.Parent.MouseButton1Down:connect(function(OMG) --Tried using a parameter to find who is trying to click it
    print("Function worked")
    local Wint=script.Parent.Parent.Parent.Parent.Parent.Parent.Winorlose.SurfaceGui.TextLabel
    if enabled==false then return end
    enabled=false
    local Spending=script.Parent.Parent.CreditsToSpend.Value

    local ValueCheck=game.Players.LocalPlayer.Credits.Value --Also tried a local value, which also didnt work as its not in their playergui.
    local CredstoGive4Winning = script.Parent.Parent.CreditsToSpend.Value * Multiplier
    print(ValueCheck)
    print(Spending)
    print(CredstoGive4Winning)

How can I get the player without LocalPlayer? Yes I tried by putting the surface gui inside the StarterGui and setting the Adornee, I found it to be very glitchy for the Slot Machine I am doing as I am using script.Parent.Parent a lot, and I also change a part that everyone can see.

1 answer

Log in to vote
0
Answered by 7 years ago

Unfortunately no, it seems that the SurfaceGui must be placed in a PlayerGui to grab the localplayer (according to the wiki). You might however be able to use a local script on the part gui where it is and send the LocalPlayer to the server via remote event or function.

--LocalScript
Button=game.Workspace.Part.SurfaceGui.TextButton
server=game.ReplicatedStorage:WaitForChild('ServerEvent') --RemoteEvent created by the server

Button.MouseButton1Down:connect(function()
    server:FireServer() --Will pass the LocalPlayer to the server by default
end)
Ad

Answer this question