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

Why is this Save script not working?

Asked by
SuperFryX 130
9 years ago

I want this script to display an image of a player and then save it so you can make changes to it in game. It does displays the players image correctly, and it updates it when the value (playername in this case) is changed. However, when I come back the value is not the same. I don't know too much about DataStores so I'm probably making a simple mistake.

playername=game.Lighting.PlayerName
sp=script.Parent
sp.Decal.Texture="http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username="..playername.Value

function onChange()
    sp.Decal.Texture="http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&  username="..playername.Value
    local dsservice = game:GetService("DataStoreService")
    local datastore = dsservice:GetDataStore("MOTWString") --Here you're either getting a datastore that already exists, or making a new one.

    datastore:SetAsync("String", game.Lighting.PlayerName.Value) --Saving the StringValue object's Value to the key, "String", in the DataStore that we're using a variable for.

    end


playername.Changed:connect(onChange)

Answer this question