I have been trying to make a cash register for a game and I want to store the name of the cashier into a StringValue.
Code: (LocalScript)
plr = game.Players.LocalPlayer add = function() -- local add = function() doesn't work either script.Parent.Parent.Parent.Parent.CustomerSide.Frame.LastAdded.Text = "Last added: " .. script.Parent.ItemName.Value script.Parent.Parent.Parent.Cashier.Value = plr.Name print(plr.Name) end script.Parent.ImageButton.MouseButton1Click:connect(add) script.Parent.TextButton.MouseButton1Click:connect(add)
This code doesn't execute add() for some reason
EDIT: Using a regular Script instead of LocalScript does execute add() but it doesn't work with game.Players.LocalPlayer
Local scripts cannot change values on the server, as any changes made will only appear to happen for that client due to the client server model. To fix this, you can look into sending a remote event to the server to update the value from a server script.
plr = game.Players.LocalPlayer function add() -- local add = function() doesn't work either script.Parent.Parent.Parent.Parent.CustomerSide.Frame.LastAdded.Text = "Last added: " .. script.Parent.ItemName.Value script.Parent.Parent.Parent.Cashier.Value = plr.Name print(plr.Name) end script.Parent.ImageButton.MouseButton1Click:connect(add) script.Parent.TextButton.MouseButton1Click:connect(add)
Try now??