Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can you save your data for every server?

How can we save data just like coins datastore i tried as a test to once the part was touched it will change color to red and save it forever but it didn't work I'm just curious if we can make it happen with datastore and how?

I saw Alvin Blox's video to create it

https://www.youtube.com/watch?v=DkYupSBUpes&t=617s

Yes i edited it and put part and things that i should put there but it still didn't work. here is the script take a look :

local Part = game.Workspace.Part
local player = game.Players.LocalPlayer
local DataS = game:GetService("DataStoreService")
local GetPart = DataS:GetDataStore("GetPartStuff")

game.Players.PlayerAdded:Connect(function(player)
	Part.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		Part.Color = Color3.fromRGB(255,0,0)
		DataS:GetAsync(player.UserId)
	end
end)
end)

	game.Players.PlayerRemoving:Connect(function(player)
	GetPart:SetAsync(player.UserId,Part.Color == Color3.fromRGB(255,0,0))
	end)

1 comment

0

first assign a variable to the data inside DataS:GetAsync(player.UserId) then load that color, second save that color as a string or as 3 numbers, idk if .Color itself can save

1 answer

You made the actual datastore but didn't use it right because you did DataS:GetAsync(). You were supposed to do GetPart:GetAsync()

To Fix it do this

game.Players.PlayerAdded:Connect(function(player) Part.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then Part.Color = Color3.fromRGB(255,0,0) GetPart:GetAsync(player.UserId) end end) end)

Code

https://pastebin.com/RmSJLPyu

To get the data

You saved the data right though.

This discussion is preserved as it was. New answers, comments, and votes are closed.