Can somebody help me fix this script? So it does half of what it's supposed to do. The second part, was from someone else helping me out, but it may have some errors to it. I need some fixes, so here's what part 2 is supposed to do, and part 1 is supposed to do
Part 1 is supposed to insert the ID, of the texture into the texture link, so it will change the swords TextureID, to what you put in it. This script works, so It doesn't need any fixes.
repeat wait() until game.Players.LocalPlayer local player = Game.Players.LocalPlayer local swordMesh = script.Parent local GuiBar = player.PlayerGui.ScreenGui.Frame.TextBox GuiBar.FocusLost:connect(function() pcall(function() swordMesh.TextureId = "http://www.roblox.com/asset/?id="..tostring(tonumber(GuiBar.Text)-1) end) end)
However part 2 is the one that's bugging me. Part 2 is supposed to save the texture so when a player was to die, then they would keep it. So it'd resolve the issue with people having to put the ID into the GUI constantly. Part 2 doesn't work, can somebody fix this?
function saveData(player) player:SaveInstance("SwordTextureId", swordMesh.TextureId) end function loadData(player) swordMesh.TextureId = player:LoadInstance("SwordTextureId") end function onUpdate() if game.Players.LocalPlayer.Character.Humanoid.Health <= 0 then saveData(game.Players.LocalPlayer) end wait(0.5) onUpdate() end
I believe this was the error:
function saveData(player) player:SaveInstance("SwordTextureId", swordMesh.TextureId) end function loadData(player) swordMesh.TextureId = player:LoadInstance("SwordTextureId") end function onUpdate() if game.Players.LocalPlayer.Character.Humanoid.Health <= 0 then loadData(game.Players.LocalPlayer) --It used to be saveData, but I changed it to loadData, maybe that will help end wait(0.5) onUpdate() end
No, you didn't understand, I pm you the entire code, As I wrote in the last part, the "getplayerhealth" method is not called.
You dont need to use GetPlayerHealth method, you can use this
game.Players.LocalPlayer.Character.Humanoid.Health