How can I clone a tool with the text I want?

Hello. I’m trying to copy a text variable onto a TextLabel inside of a Tool. Do I need to path a way into the player’s backpack and change it there? Or do I use StarterPack instead?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local numberService = ReplicatedStorage:WaitForChild("LotteryNumberService") 
local LotteryCard = game:GetService("Lighting")["Lottery Card"]
local LotteryCardText = LotteryCard.LotteryCard.SurfaceGui.TextLabel.Text
local function onButtonPress(player, text)
	local playerNumber = tonumber(text)
	if typeof(playerNumber) == "number" then 
		if playerNumber >= 0 and playerNumber <= 100 then
		end
	end
end

numberService.OnServerEvent:Connect(function(player, text)
	print(player, text)
	onButtonPress(player, text)
	LotteryCardText = text
	local clone = LotteryCard:Clone()
	clone.Parent = game.Players[player.Name].Backpack
end)

This is a server script inside of ServerScriptStorage.
Here’s a picture of the explorer.
image
I think the issue is that it only clones the tool itself, not the tool AND anything that’s a child of it. Not sure though.

Any help is greatly appreciated.

You’re not setting the Text of the TextLabel inside the cloned LotteryCard
Here:

local clone = LotteryCard:Clone()
clone.LotteryCard.SurfaceGui.TextLabel.Text = text
clone.Parent = game.Players[player.Name].Backpack
1 Like

I see. I tried that but forgot that I’m cloning a tool and didn’t path into the lottery card part itself. Thank you so much.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.