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

Why wont this work??

Asked by 10 years ago

Why wont this work?? Nothing wrong with output, it just wont work.

local player = Game.Players.LocalPlayer
local swordMesh = script.Parent
local GuiBar = player.PlayerGui.ScreenGui.TextBox --Change to correct path.
GuiBar.FocusLost:connect(function()
    pcall(function()
        swordMesh.Texture = "http://www.roblox.com/asset/?id="..GuiBar.Text --Try to change the texture.
    end)
end)

3 answers

Log in to vote
1
Answered by 10 years ago

It's TextureId mostly, depending on what you're changing:

local player = Game.Players.LocalPlayer
local swordMesh = script.Parent
local GuiBar = player.PlayerGui.ScreenGui.TextBox
GuiBar.FocusLost:connect(function()
    pcall(function()
        swordMesh.TextureId = "http://www.roblox.com/asset/?id=" .. (GuiBar.Text)
    end)
end)

Also, with roblox you are wanting to get the base image of the decal, so take 1 off the ID when you type it in. E.g. if the ID of the decal is 141225665 then when you type it in change it to 141225664.

0
That wont work either. Help please??? Lem0nzz 5 — 10y
0
Are you sure that: 1. The script is a localscript 2. The parent of the script is the Mesh 3. Inside your player's PlayerGui there is a ScreenGui named ScreenGui and inside that is a TextBox named TextBox Archonious2 160 — 10y
0
I have a feeling your TextBox path is incorrect. Archonious2 160 — 10y
Ad
Log in to vote
1
Answered by 10 years ago
local player = Game.Players.LocalPlayer
local swordMesh = script.Parent
local GuiBar = player.PlayerGui.Example.TextBox --Change to correct path.
GuiBar.FocusLost:connect(function() --When someone is finished typing into the TextBox,
    pcall(function() 
        swordMesh.TextureId = "http://www.roblox.com/asset/?id="..tostring(tonumber(GuiBar.Text)-1) --Try to change the texture.
    end)
end)

Should function correctly.

0
Didn't work. Lem0nzz 5 — 10y
0
Is the path to the TextBox correct? Articulating 1335 — 10y
Log in to vote
0
Answered by
sigve10 94
9 years ago

First things first: Is this in a LocalScript?

If it is: I have no idea what can have caused it

If it isn't: It's most probably the reason, as focuslost happens on a client. Copy the code into a localscript and it will most probably work

Answer this question