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

My string value will not update from a script, it just uses the default value?

Hey, so, I'm pretty sure I am being really dumb right now, however, I'm still going to ask. My problem is this: When I set a value in a script it won't update for my script when It sends its data.

This is my script that changes a value called 'Q1' in 'game.Workspace.OSLoader.Answers.Q1.Value'

script.Parent.Submit1.MouseButton1Down:Connect(function(player)
	game.Workspace.OSLoader.Answers.Q1.Value = script.Parent.Box1.Text
end)

script.Parent.FeedbackButton.MouseButton1Down:Connect(function(player)
     wait()
     game.Workspace.OSLoader.Events.SPACER:FireServer("SpacerSent")
	 wait(1.5)
	 game.Workspace.OSLoader.Events.R1:FireServer("R1Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R2:FireServer("R2Sent")
	 wait()
     game.Workspace.OSLoader.Events.R3:FireServer("R3Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R4:FireServer("R4Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R5:FireServer("R5Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R6:FireServer("R6Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R7:FireServer("R7Sent")
	 wait()
	 game.Workspace.OSLoader.Events.R8:FireServer("R8Sent")
     wait()
end)

At the top I am making it so when my button is pressed it sets the 'Q1's value to the text boxes text. This works fine I can see that it has changed the value, however when I use this script to post a message to google sheets it is blank (The default value of a string value)

databaseService = require(script.DatabaseService)
local globalDatabase = databaseService:GetDatabase("Global")

local Q1 = game.Workspace.OSLoader.Answers.Q1.Value

game.Workspace.OSLoader.Events.SPACER.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Name: "..player.Name.."  |  UserId: "..player.userId,"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
end)

game.Workspace.OSLoader.Events.R1.OnServerEvent:Connect(function(player)
	globalDatabase:PostAsync("Q1 From "..player.Name,Q1)
end)

game.Workspace.OSLoader.Events.R2.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q2 From "..player.Name,"Working? TEST2")
end)

game.Workspace.OSLoader.Events.R3.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q3 From "..player.Name,"Working? TEST3")
end)

game.Workspace.OSLoader.Events.R4.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q4 From "..player.Name,"Working? TEST4")
end)

game.Workspace.OSLoader.Events.R5.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q5 From "..player.Name,"Working? TEST5")
end)

game.Workspace.OSLoader.Events.R6.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q6 From "..player.Name,"Working? TEST6")
end)

game.Workspace.OSLoader.Events.R7.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q7 From "..player.Name,"Working? TEST7")
end)

game.Workspace.OSLoader.Events.R8.OnServerEvent:Connect(function(player)
    globalDatabase:PostAsync("Q8 From "..player.Name,"Working? TEST8")
end)

print(globalDatabase:GetAsync("Cool People"))

It just won't update it, I don't understand why, If you can help that would be great!

-ItsDodgee

1 comment

0

v

1 answer

You have set Q1 directly to the value, this will act like Q1 = "SomeValue", and this wont ever update. Instead, set Q1 to the instance, and use Q1.Value whenever you need the value.

6 comments

0

So, would I do

0

So, would I do 'local Q1 = game.Workspace.OSLoader.Answer.Q1 then when I need to use Q1, I would do Q1.Value?

0

I dont understand what you mean..

0

Yes, that's exactly what you have to do.

0

3333 reps

0

I tried that but It didn't work..

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