Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

4 comments

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

0

it dosent work it i change the varible to target either

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

0

In the target variable above, remove .Text and add it where your print is. print(target.Text)

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.