So what I'm trying to do is make a type of machine that gives you tickets. What you would do is type your username or someone else's into a TextBox and click a TextButton to give the player that has the username which you inserted a ticket. The problem I'm having is that it won't work when you're trying to give the ticket to another player. Instead, it would only work when you would give the Ticket to yourself. I've already tried both Local and Regular scripts.
-------Down below is the script that I used for giving the ticket to the player and getting its username.
-------------------------------Getting Player's Name and Giving Ticket
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.StringValue.Value = script.Parent.Parent.TextBox.Text
-----Getting username inserted in the TextBox into a StringValue
wait()
local Name = script.Parent.Parent.PlayerName.Value
--- Getting the value from the StringValue
local TicketToGive = game.Players:WaitForChild(Name)
--- Finding Player
local Clone = game.ReplicatedStorage.Ticket:Clone()
---Cloning the Ticket from Replicated Storage
Clone.Parent = TicketToGive.Backpack
---Giving the Cloned Ticket to the Player.
end)

1 comment
did you look into remote events?