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

Script Won't Change The Texture? [SOLVED]

Asked by 4 years ago
Edited 4 years ago

I've looked for 2 hours now and just keep finding the same answer over and over. But the problem is, the answer doesn't work for me.

I'm trying to make a script that changes a player's face when they put in an id. I've looked up YouTube tutorials, looked at other answers on questions, but none of it has helped me. I do it the same as YouTube and yet it still doesn't work. Unless it has to go in a LocalScript (Which I don't think so, but I'm not certain) I have no idea. Help is very much appreciated.

ServerScript:

game.ReplicatedStorage.Appearance.OnServerEvent:Connect(function(plr, key)
    local Char = game.Workspace:FindFirstChild(plr.Name)
    local newTexture = "rbxassetid://" .. key

    Char.Head.face.Texture = newTexture
end)

LocalScript:

script.Parent.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        game.ReplicatedStorage.Appearance:FireServer(script.Parent.Text)
    end
end)
0
Also, there's no output when it runs. kkkeelan999 92 — 4y
0
how are you getting the key? ahsan666666666666 264 — 4y
0
When the LocalScript fires the RemoteEvent it's sending the script.Parent.Text to the ServerScript, which in this case is the id that the player put in. kkkeelan999 92 — 4y
0
Where did you put the serverscript? (i recommend to put it in ServerScriptService.) MythsList 38 — 4y
View all comments (2 more)
0
What is "FocusLost"? If it is a value object then I suggest that the problem may be that you are entering the object and not the Value inside it. Sebgamingkid 147 — 4y
0
FocusLost refers to when someone stops typing in the TextBox, i.e. When the flashing bar goes away. The ServerScript is already in ServerScriptService and the LocalScript is in the TextBox in the PlayerGui. Sorry, I should've explained these things in the question. kkkeelan999 92 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

hey i somehow found the answer. i think what your doing wrong is your using "rbxassetid://" .. key

what i did for my script was:

(BTW this is a server script placed inside StarterPlayer, StarterCharacterScripts)

game.ReplicatedStorage.test.OnServerEvent:Connect(function(plr, ide)
    script.Parent.Head.face:Destroy()
    local face = Instance.new("Decal", script.Parent.Head)
    face.Texture = "http://www.roblox.com/asset/?id="..ide
    face.Name = "face"
end)

i used "http://www.roblox.com/asset/?id=" for my link thing. i got rid of any spaces in between the the link the .. and the ide (which for you would be key) i also changed the link format thing. not sure what you call it. and i made it where it would destroy any old face that was already there and replace it with a new one. and if that doesn't work i recommend going to the gui and adding a textbutton rather then seeing if the player presses enter because i feel like its something thats more guaranteed to work. heres the local script i used in my gui:

script.Parent.MouseButton1Click:Connect(function()
    local ide = script.Parent.Parent.TextBox.Text
    game.ReplicatedStorage.test:FireServer(ide)
end)

this is placed inside the text button.

anyway i hope this helped you!

0
“rbxassetid://“ works, I use it for my own scripts. The problem could be that you need too write “rbxassetid://image/“ then the name of the image not the id. Benbebop 1049 — 4y
0
i tried rbxassetit:// but it diddnt work ahsan666666666666 264 — 4y
0
I already did what you did except for using a button instead of enter, and the location of the script. Although I never tried all of them together, so that may be the clue. I'll test it and get back to you. kkkeelan999 92 — 4y
0
I copy and pasted your code and it still didn't work. I'm gonna try it in a new game to see if something already in my game is messing with it. kkkeelan999 92 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

So... Nothing was working, and come to find out, I needed to get the id from the linked item, not the item on the catalog... Sorry to everyone that tried to help for wasting your time. :/

(My original script did work, I was just getting the wrong id)

0
oh lol ahsan666666666666 264 — 4y

Answer this question