local OrderName = script.Parent.Text
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player:WaitForChild("OrderVal").Value = OrderName
end)
MouseButton1Click doesn’t return anything, so you won’t expect it to return a player. Also, the variable OrderName will just stay constant. I assume this is a normal script, so you’d do:
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
player:WaitForChild("OrderVal").Value = script.Parent.Text
As said by the post above, MouseButton1Click does not return a player object. It doesn’t need to as there is one instance of the local script (and GUI) per player and you can get that player object when the script is initialised:
local player = game.Players.LocalPlayer
local OrderName = script.Parent.Text
script.Parent.MouseButton1Click:Connect(function()
player:WaitForChild("OrderVal").Value = OrderName
end)
Yes, grab the local player at the start and then you can refer to it in all your functions.
If you replace your current code with the one I posted it should work as you intend.
I can see from the scripts full name that the script is a local script affecting a button, in the Player UI using local scripts player is not an argument - you are likely confusing this with BillboardGui and SurfaceGui or even click detectors which rely on scripts within the workspace to operate (mainly).
As such to get the player you can just do game.Players.LocalPlayer in the local script for the same result.