The problem is you need to check the text every time you click the thing, also you need to check if the ID is a number.
Local Script:
01 | local InsertService = game:GetService( "InsertService" ) |
02 | local remoteEvent = game:GetService( "ReplicatedStorage" ):WaitForChild( "RemoteEvent" ) |
04 | script.Parent.MouseButton 1 Click:Connect( function () |
05 | local ID = script.Parent.Parent.IdHolder.Text |
07 | remoteEvent:FireServer(ID) |
08 | script.Parent.Parent.Display.Text = "Success" |
10 | print ( "Not a number!" ) |
Also another note, localscripts cant load assets, so you have to have a remote event in ReplicatedStorage and a script in ServerScriptService
Server Script:
1 | game:GetService( "ReplicatedStorage" ):WaitForChild( "RemoteEvent" ).OnServerEvent:Connect( function (ID) |
2 | local Model = InsertService:LoadAsset( tonumber (ID)) |
3 | local NewModel = Model:GetChildren() [ 1 ] |
4 | NewModel.Parent = workspace |
And it should work!
If you want to learn more about remoteevents then go here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
I hope this helped you!