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

Can somebody help me fix this script?

Asked by 10 years ago

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

3 answers

Log in to vote
0
Answered by 10 years ago

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
0
Didn't work. Wrongmistake 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

No, you didn't understand, I pm you the entire code, As I wrote in the last part, the "getplayerhealth" method is not called.

0
I don't understand still.. Wrongmistake 0 — 10y
0
You called "onUpdate()" when there wasn't a function named like that, you called it inside a NOT called function. alessandro112 161 — 10y
0
Oh, I saw that you put 2 end at the end of the code, anyway the code I gave should work alessandro112 161 — 10y
Log in to vote
0
Answered by 10 years ago

You dont need to use GetPlayerHealth method, you can use this game.Players.LocalPlayer.Character.Humanoid.Health

0
Still, I need help with this it wont work. Wrongmistake 0 — 10y
0
Then give us the last part! RobloxMinecraftDK 0 — 10y

Answer this question