Changing a Decal Texture to the Text in a TextBox

I’m trying to make this script change the Decal Texture, however every time I do that, it prints it’s not a number and is printing my username as the entered text, not really sure why though.

Local Script

local rs = game:GetService("ReplicatedStorage")

script.Parent.OnButton.MouseButton1Click:Connect(function()
	-- Check if the text has changed and is not empty
	if script.Parent.ImageIDTextBox.TextBox.Text ~= "" then
		local enteredText = script.Parent.ImageIDTextBox.TextBox.Text

		-- Fire the remote event to the server
		rs.UpdateTVs.UpdateAllTVs:FireServer(enteredText)
	end
end)

Server Script

local rs = game:GetService("ReplicatedStorage")

-- Define a RemoteEvent for clients to send the text box content
local updateTVsEvent = rs.UpdateTVs.UpdateAllTVs

-- Function to update TV textures based on received text
local function updateTVs(text)
	-- Check if text is not empty
	if text ~= "" then--and #text <= 19 then
		local possibleAssetID = tonumber(text)
		if possibleAssetID then
			-- Update TV textures with the asset ID
			local tv = game.Workspace:WaitForChild("TVs"):WaitForChild("MiddleTV").Display.Screen
			local tv2 = game.Workspace:WaitForChild("TVs"):WaitForChild("RightTV").TV.Display.Screen
			local tv3 = game.Workspace:WaitForChild("TVs"):WaitForChild("LeftTV").TV.Display.Screen

			tv.Texture = "rbxassetid://" ..possibleAssetID
			tv.Transparency = 0

			tv2.Texture = "rbxassetid://" ..possibleAssetID
			tv2.Transparency = 0

			tv3.Texture = "rbxassetid://" ..possibleAssetID
			tv3.Transparency = 0
		else
			print(text)
			-- Handle invalid input on the server (optional)
			print("Client sent invalid asset ID (not a number).")
		end
	else
		print(text)
		print("Asset ID is too long. Please enter a shorter ID.")
	end
end

-- Listen for the remote event from clients
updateTVsEvent.OnServerEvent:Connect(updateTVs)

I type 18166459700 in the TextBox and when I click the OnButton it detects it as my username instead of the number/asset ID.
image

image

Nevermind, I forgot to add the player on the server event in the server script,

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