How do I use a variable in a script

I am trying to add the name variable next to players but I can’t remember how.

script.Parent.Touched:Connect(function(player)
	local name = player.name
	game.Players.PlayerGui.OpenShop:FireClient()
end)

I’m not sure I understand what you want to do? But is this it?

script.Parent.Touched:Connect(function(player)
	local name = player.name
	game.Players.name.PlayerGui.OpenShop:FireClient()
end)

What I am trying to do is add the variable name into the script

That’s what I did for you there.

game.Players[name].PlayerGui.OpenShop:FireClient()

alternatively you can just

player.PlayerGui.OpenShop:FireClient()

since game.Players[name] is the same as player

4 Likes