I want a local script that gets the player when the player click in a TextButton (Inside a ScreenGui)
I can’t make it .-.
I already tried use the LocalPlayer option but this will crash other script.
I want a local script that gets the player when the player click in a TextButton (Inside a ScreenGui)
I can’t make it .-.
I already tried use the LocalPlayer option but this will crash other script.
Why does game.Players.LocalPlayer
crash? Did you forget to write Players
before LocalPlayer
?
Also show the script pls ;-;
I don’t think that could crash a device?
Place a local script under the button and type:
script.Parent.MouseButton1Click:Connect(function(click)
local player = game.Players.LocalPlayer
print(player.Name.." pressed the button.")
end)
I tried it and it doesn’t crash the device at all and it works perfectly.
It doesn’t crash this local script, but crash the other script of the serverscriptservice, because it’s firing a remote event.
Because the other script thinks that the LocalPlayer is all players.
The only thing I can think of is using a MouseButton1Click Parameter
TextButton.MouseButton1Click:Connect(Function(Player)
Print(Player)
End)
Maybe something in the lines of that meets your intention?
It print “nil” and if i put Player.Name, appear an error saying that the parameter doesn’t have a name
Oh, I tought it would work since I have seen other problems similar to this, but never tried it, I hope you will find a solution for this
This is incorrect syntax and there’s no Player
parameter for the GuiButton.Mousebutton1Click event.
When calling RemoteEvent:FireServer() in a LocalScript, the receiving end which will be the RemoteEvent.OnServerEvent event in a Script will always have its first parameter reserved for the Player instance which refers to the player who fired the event.
Read this for a thorough tutorial regarding the topic: Bindable Events and Functions | Roblox Creator Documentation