Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can my trail not find the decal ID? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

This PART OF A SCRIPT is supposed to change the texture of a trail in the player. So someone puts a decal id in the input* in a text box and then clicks a button (script.Parent) the trail texture changes to the decal id in the input.

trail.Texture = "http://www.roblox.com/asset/?id=".. script.Parent.Parent.Input.Text --Input*

This is the error I get:

Image "https://assetgame.roblox.com/asset/?id=2780518" failed to load in "Workspace.kittonlover101.Torso.Trail.Texture": Request failed

Thanks!

2 answers

Log in to vote
0
Answered by 5 years ago

You should wrap those kinds of things in a pcall, since any kind of text can go in a TextBox.

local input = script.Parent.Parent.Input

local success, msg = pcall(function()
    trail.Texture = "http://www.roblox.com/asset/?id="..input.Text
end)

if success then
    -- code
else
    error("An error occurred:", msg)
end
0
Ok im not to sure where to put this? Because it's not working... kittonlover101 201 — 5y
0
Also what code do I put in the --if success then-- part? kittonlover101 201 — 5y
0
Repeat my line 4 in line 8 User#19524 175 — 5y
0
Ok kittonlover101 201 — 5y
View all comments (2 more)
0
Humm. Still doesn't work. It puts the decal id in the texture thing, but it still doesn't show up... /: kittonlover101 201 — 5y
0
Image "https://assetgame.roblox.com/asset/?id=2148129" failed to load in "Workspace.kittonlover101.Torso.Trail.Texture": Request failed kittonlover101 201 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Sometimes you'll have to subtract the ID by one or sometimes even more than one. I think this is because of images and decals being different but I don't remember.

I would simply do this :

trail.Texture = 'rbxassetid://'..tonumber(input.Text) - 1 -- May sometimes have to subtract more than one sometimes

I use 'rbxassetid://' since it's much shorter. I then use tonumber to get the number of the ID and subtract it by one. Now when you put in the ID, the ID will subtract itself by one and it'll work.

0
A decal has a Image. kittonlover101 201 — 5y

Answer this question