local target = script.Parent.Parent.Target.Text local rank = script.Parent.Parent.Rank.Text local change = script.Parent local Players = game:GetService("Players") change.MouseButton1Click:Connect(function() print(target) local Target = game.Workspace:WaitForChild(target123) if Target then print(Target.Name) Target.Head.title.rank.Text = rank end end)
the print statement in line 6 is always printing target for no reason what could be the cause?
okay so you should put the target variable inside of the function because target is going t be the text as soon as the script runs
local change = script.Parent local Players = game:GetService("Players") change.MouseButton1Click:Connect(function() local target = script.Parent.Parent.Target.Text local rank = script.Parent.Parent.Rank.Text print(target) local Target = game.Workspace:WaitForChild("target123") if Target then print(Target.Name) Target.Head.title.rank.Text = rank end end)