You're misunderstanding variable assignment and property allocation.
This is a common mistake in the early stages of learning to program with game engines. In ROBLOX, you cannot make pointers to an Instance's property. When you reference the .Text
value, the compiler in this context will be storing the said value in your variable "text".
To resolve your problem, only reference .Text
when you intend to change this property:
01 | local Player = game.Players.LocalPlayer |
03 | local TextLabel = player.PlayerGui.GunPick.Screen.LoadoutInfo.ChangeableInfo.Primary |
04 | local Button = script.Parent |
07 | Button.MouseButton 1 Click:Connect( function () |
09 | TextLabel.Text = "Martini Henry" |