Ok so I am remaking an old game of mine and I ran into an error. The part of the script in the error is the main menu and it should play when the player joins.
The code:
if true then
script.Parent.slowsleigh:Play()
fadegui({intro.load},{0},{1},30)
wait(1)
local titles = intro.titles
local text1 = titles.title1.Text
local text2 = titles.title2.Text
local text3 = titles.title3.Text
local text4 = titles.title4.Text
if GameData.entered == 1 then
text1 = "And you came back."
text2 = "You can't change the past."
text3 = "Pathetic."
end
titles.title1.Text = ""
titles.title2.Text = ""
titles.title3.Text = ""
titles.title4.Text = ""
--[
titles.title1.Visible = true
for i = 1, #text1 do
titles.title1.Text = string.sub(text1,1,i)
wait(0.05 + math.random(-5,10)/200)
end
wait(1)
titles.title1.strikeout:TweenSize(UDim2.new(1,0,0,3),"Out","Quad",0.5)
wait(0.5)
titles:TweenPosition(titles.Position + UDim2.new(0,0,0,-48),"Out","Quad",0.5)
fadegui({titles.title1},{0},{0.5},15)
wait(0.5)
titles.title2.Visible = true
for i = 1, #text2 do
titles.title2.Text = string.sub(text2,1,i)
wait(0.05 + math.random(-5,10)/200)
end
but when I go to playtest it, I get this error
(Blurred my username because I’m on an alt)
So does anyone know what I can do to fix it?
What exactly is GameData? Apparently GameData is nil
1 Like
I genially don’t remember the only other part that mentions it is this
local GameData = workspace:WaitForChild("GetData"):InvokeServer()
local SetFunc = workspace:WaitForChild("SetData")
local SetData = function(dat)
SetFunc:FireServer(dat)
end
if it helps this is the full command output
Are you returning anything in the ServerScript that handles the GetData RemoteFunction?
Also, “if true then” will always be true, so you don’t really need the statement
1 Like
ServerScriptService has one script called “data” that includes
local data = game:GetService("DataStoreService"):GetGlobalDataStore()
local dataVersion = 2
local func = Instance.new("RemoteFunction",workspace)
func.Name = "GetData"
function func.OnServerInvoke(player)
local store = data:GetAsync(tostring(player.UserId))
return store
end
local set = Instance.new("RemoteEvent",workspace)
set.Name = "SetData"
set.OnServerEvent:connect(function(player,newData)
local store = data:GetAsync(tostring(player.UserId))
for i,v in pairs(newData) do
store[i] = v
end
data:SetAsync(player.UserId,store)
end)
Hmm. Is there any function which assigns data to your GlobalDataStore on this or other ServerScirpt? It would look something like this:
data:SetAsync(player.UserId, data)
1 Like
yep
local set = Instance.new("RemoteEvent",workspace)
set.Name = "SetData"
set.OnServerEvent:connect(function(player,newData)
local store = data:GetAsync(tostring(player.UserId))
for i,v in pairs(newData) do
store[i] = v
end
data:SetAsync(player.UserId,store)
end)
the only difference is it uses “store” instead of “data” for some reason
Edit: nvm I found out why it uses store
function func.OnServerInvoke(player)
local store = data:GetAsync(tostring(player.UserId))
return store
end
Ok so I’m still not sure what I’m doing wrong. But I did find something with “entered” in it and I’m thinking this might be why it wont work
SetData({entered = 1})