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

Why can't I use data persistance?

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

2 comments

0

Any answers?

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.

1 answer

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.

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