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

Why can't I use data persistance?

Asked by 10 years ago
local brick = game.Workspace.redgate.gate

function onTouch(brick)
    player:WaitForDataReady() 
    player:SaveString("team", "painless")
    game.Players:findFirstChild(brick.Parent.Name).PlayerGui.ScreenGui.TextBox.Text = player:LoadString("team")
end 

brick.Touched:connect(onTouch)

Hello, I posted this on Scripting Helpers (forum) but had no replies. I see no reason for it to not work. It is supposed to set a datapersistance and then set the text in the GUI to the team name.

Thanks in advance, Darklaer.

UPDATE: I checked the output and saw this in it: gate is not a valid member of Script

0
Any answers? Darklaer 0 — 10y
0
Data persistence should no longer be used because it has been deprecated. Use data stores instead, they are much more reliable and they allow you to save much more information. FearMeIAmLag 1161 — 10y

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago
brick = game.Workspace.redgate.gate

function onTouch(hit)
if hit~=nil then
if game.Players:FindFirstChild(hit.Parent.Name) then
local player = game.Players:FindFirstChild(hit.Parent.Name)
    player:WaitForDataReady() --You didn't define the player yet.
    player:SaveString("team", "painless")
    player.PlayerGui.ScreenGui.TextBox.Text = player:LoadString("team")
end
end
end 

brick.Touched:connect(onTouch)

What might have been the problem was the script may have been confusing the two brick tags, as one was defined to the red gate, and another was defined to the person hitting the brick.

Ad

Answer this question