Image won't change

local player = game.Players.LocalPlayer
local character = player.Character
local icon = game.ReplicatedStorage.ICON
local copyicon = icon:Clone()
local decal = player.PlayerGui.Icon.Frame.TextBox.Text
copyicon.Parent = character.Head
copyicon.ImageLabel.Image = ("rbxassetid://"..decal)

idk why this does not work. im trying to make it so the player can change an image that’s above their head as they wish, when they insert a decal id/ into a textbox.

You need to detect when they press enter.
The code is running just one time, resulting on current decal. Link a function on a event to it execute the image change code part.

Here about text box. You can link it when TextBox lost player focus or when he press ENTER, on 2° case you need to use UserInputService.

Adding to what @PedroGame007Pg has said,

Try this:

local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Icon = Replicated:WaitForChild("ICON")
local clone = Icon:Clone()
local current_decal = Player:WaitForChild("PlayerGui"):WaitForChild("Icon").Frame.TextBox.Text

clone.Parent = Character:WaitForChild("Head")
clone.ImageLabel.Image = "rbxassetid://"..tonumber(decal)
1 Like