Datastore2 Text wont update

hello !
i actually want to make a system where when the player click on a button, a textbox update with a text inside. And i dont know it dont work :confused:

replicatedStorage.data.premier.OnServerEvent:Connect(function(player)
	print("HELO")
	local location = DataStore2("location", player)
	location:Set("Land")
end)

local script

local label = script.Parent

local replicatedStorage = game:GetService("ReplicatedStorage")

replicatedStorage.data.premier.OnClientEvent:Connect(function(lieu)

label.Text = lieu

end)

What does this have to do with DataStore2?

Also could you please be a bit specific with the titles and what you need then we can help you!

1 Like

because later i need this values. ( and yes sure )

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")
local replicatedStorage = game:GetService("ReplicatedStorage")

local DataStore2 = require(ServerScriptService.DataStore2)
local defaultEndurance = 20
local defaultValue = 50
local defualtXpValue = 1
local defaultValueLevel = 1
local defaultValueEndurance = 20
local defaultLocation = "Land"
local lieu1 = "Arestia"
--local button = game.StarterGui.Main.TextButton

Players.PlayerAdded:Connect(function(player)
	
	-- DATASTORE
	
	local enduranceStack = DataStore2("endurance", player)
	local currencyStore = DataStore2("currency", player)
	local actualLevel = DataStore2("level", player)
	local actualXp = DataStore2("xp", player)
	local location = DataStore2("location", player)
	
	-- LOCATION
	
	local function updateClientLocation(lieu)
		replicatedStorage.data.location:FireClient(player,lieu)
	end
	
	updateClientLocation(location:Get(defaultLocation))

and this script is the script for the button

--variable

local button = script.Parent

--local location = button.ImageLabel

local PLACE1 = button.Parent.PLACE1

local PLACE2 = button.Parent.PLACE2

local PLACE3 = button.Parent.PLACE3

local PLACE4 = button.Parent.PLACE4

local PLACE1_IN = button.Parent.PLACE1_IN

local returnButton = button.Parent.returnButton

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local lieuRemote = ReplicatedStorage.data.premier

local map1 = button.Parent.map

local button_map1 = PLACE1_IN.ImageButton

local frame_map1 = PLACE1_IN.Frame

--script

--button.MouseEnter:Connect(function()

-- if location.Visible == false then

-- location.Visible = true

-- end

--end)

--button.MouseLeave:Connect(function()

-- if location.Visible == true then

-- location.Visible = false

-- end

--end)

button.MouseButton1Click:Connect(function()

lieuRemote:FireServer()

PLACE1.Visible = false

PLACE2.Visible = false

PLACE3.Visible = false

PLACE4.Visible = false

PLACE1_IN.Visible = true

returnButton.Visible = true

map1.Visible = false

button_map1.Visible = true

frame_map1.Visible = true

end)

I can vaguely make something for you:

local trigger = script.Parent
local boxtoupd  = script.Parent.Parent.BoxToUpdate
local text = "Your text goes here"

script.Parent.MouseButton1Click:Connect(function()
boxtoupd.Text = text
end)

As I just saw your recent post I know this wont help much but I just wanted to point it out.

1 Like

oh okay! its a smart idea ! thx a lot i think it work. but with this system, i cant save it right ?

You welcome, well you can save it if you change the values, but I, personally, have never used Datastore2 before.
You can try this:

Be sure to solution this if its solved so other people dont need to come here even though its solved!

1 Like

yes sure thx you a lot ! it help me a lot

Also this should help too!

You welcome, dm me if you have any other questions!

1 Like