I need to make a button that it will copy Text from a TextBox when clicked and paste it into a StringValue. Here is the code I tried:

script.Parent.MouseButton1Click:Connect(function()
	if game.ReplicatedStorage.Maps[script.Parent.Parent.KickPlayer.Text] == nil then
		script.Parent.Text = "Selected Minigame does not exist!"
		script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
		wait(2)
		script.Parent.Text = "Confirm Selection"
		script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
	elseif game.ReplicatedStorage.Maps[script.Parent.Parent.KickPlayer.Text] ~= nil then
		game.ReplicatedStorage.vals.NextMinigame.Value = script.Parent.Parent.NextMinigame.Text
	end
end)

How can I fix it? I would appreciate help! Thanks! -JBennettChief9

3 comments

0

The Text property can't be nil, as nil defines non-existent. Compare as an empty string "".

0

That isn't what it it's doing. it's finding an Item with the same Text

0

Right, my bad I read the script too fast;)