I’m working on my first ever datastore system for a game, and the way I am trying to make my values for each player secure from exploiters is by storing it inside of serverstorage. When each player joins, they get a intvalue created with their UserId as the name.
I’m trying to make a basic version of what I’m trying to make, and here’s what I’ve got so far:
--Server Script
event.OnServerEvent:Connect(function(player, text)
local value = game.ServerStorage:WaitForChild(player.UserId)
text = (value.Value)
end)
-- Local Script
while true do
game.ReplicatedStorage.RemoteEvent:FireServer(text)
wait()
end
For some reason, text is not changing to the value specified for the player. Im getting no errors, and I’m not really sure what is the reason.
1 Like
you probably wanted to do this
--Server Script
event.OnServerEvent:Connect(function(player, text)
local value = game.ServerStorage:WaitForChild(player.UserId)
value.Value = text
end)
1 Like
I am not trying to set value to text, im trying to set text to value, but I believe I still made a mistake and i revised it:
event.OnServerEvent:Connect(function(player, text)
local value = game.ServerStorage:WaitForChild(player.UserId)
text = value.Value
end)
Still no outputs and the textlabel is not outputting value.Value
Ok, I understood. So what you want is this
-- Server Script
game:GetService("Players").PlayerAdded:Connect(function (player)
local playerText = Instance.new("StringValue")
playerText.Parent = game.ServerStorage
playerText.Value = "Hi"
playerText.Name = player.UserId
while true do
--local value = game.ServerStorage:WaitForChild(player.UserId)
game.ReplicatedStorage.RemoteEvent:FireClient(player, playerText.Value)
wait(1)
end
end)
-- Local Script
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
remote.OnClientEvent:Connect(function(textValue)
text.Text = textValue
end)
text
is the TextLabel
thankyou! it works perfect, i never thought of using fireclient but this is much more efficient than whatever i was trying to do
Dont Forget Click Solution Button If It Help You!
1 Like