Hello, so I have a script which is suppose to make the id in the textbox import into roblox, though I am very new to accessory part of scripting, here is my script
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
script.Parent.FocusLost:connect(function(enterPressed)
if enterPressed then
local Load = game:GetService("InsertService"):LoadAsset(script.Parent.Text)
Load.Parent = character
for i, v in pairs(Load:GetChildren()) do
v.Parent = character
end
end
end)
end)
end)
I think you have to convert the Text to a number since Text is automatically a string. You’ll have to do some filteing to ensure what was given is a number, but for now, you could do
local Load = game:GetService("InsertService"):LoadAsset(tonumber(script.Parent.Text))
Wait yea now taht I see it carefully, why is in a PlayerAdded and characterAdded? Couldn’t you just make it a separate event and just parent it to the local player’s character? This is in a Localscript correct?
Server scripts can’t see text inputted by the client. You will have to change it to a local script. To get the player you can do game.Players.LocalPlayer and game.Players.LocalPlayer.Character to get their character
local PLAYER_SERVICE = game:GetService("Players")
local PLAYER = PLAYER_SERVICE.LocalPlayer or PLAYER_SERVICE:FindFirstChild("NameHere") or PLAYER_SERVICE:WaitForChild("NameHere")
-- We wait for PLAYER variable to be available, then we move on from there.
local CHARACTER = Player.Character or Player.CharacterAdded:Wait()
script.Parent.FocusLost:connect(function(ENTER_PRESSED)
if ENTER_PRESSED then
-- I copied and pasted the code to here.
local Load = game:GetService("InsertService"):LoadAsset(script.Parent.Text)
Load.Parent = character
for i, v in pairs(Load:GetChildren()) do
v.Parent = character
end
end
end)