I want to have it so when I press a button a TextLabel changes, this is the code I've came up with but it doesn't work.
local player = game.Players.LocalPlayer local text = player.PlayerGui.GunPick.Screen.LoadoutInfo.ChangeableInfo.Primary.Text local button = script.Parent button.MouseButton1Click:Connect(function() text = "Martini Henry" end)
It doesn't give out any output errors or Script Analysis errors.
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:
local Player = game.Players.LocalPlayer local TextLabel = player.PlayerGui.GunPick.Screen.LoadoutInfo.ChangeableInfo.Primary local Button = script.Parent Button.MouseButton1Click:Connect(function() --------------- TextLabel.Text = "Martini Henry" end)