Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my script print statement always printing "target"?

Asked by 3 years ago
Edited 3 years ago
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?

0
Maybe try not to put numbers in a variable name and also it’s probably something wrong where you locate the objects, also don’t save the text value to a variable try saving the label to a variable instead of the text value o it iamtryingtofindname 22 — 3y
0
it dosent work it i change the varible to target either marsdonh 36 — 3y
0
Well that means that it is something wrong elsewhere, because you are printing the text value of the object, which means that either there is something wrong in the text box, or you are locating the wrong object, ex. You a iamtryingtofindname 22 — 3y
0
In the target variable above, remove .Text and add it where your print is. print(target.Text) BestCreativeBoy 1395 — 3y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

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)
Ad

Answer this question