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

Is it possible to save screen gui>frame>textbutton>localscript?

Asked by
tykoone -8
6 years ago

so when you exit game and load game again that textbutton's loclascript would automaticly run (so if you have clicked textbutton and localscrupt runs and you exit game next time you visit local script would run instatly

0
you can save a boolean (true or false) when you've clicked the button. you can then use that value to determine if the user has clicked it before. RubenKan 3615 — 6y
0
i not good at under standing what are you trying to say so you want me to make true or false like when false happens something then it turns to true and if true automaticly run but how is it goi g to work if exit game and come back how is true when i come back? sry im starter in studio :( tykoone -8 — 6y
0
You can use data store to save the value of the gui if it changes overtime or you set that they can change it but if it always stays the same you can save the value if its visible or not and then GetAsync. If you're confused about saving go here http://wiki.roblox.com/index.php?title=Data_store. NovusDev 25 — 6y
0
thx for giving that link you are the best! tykoone -8 — 6y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

From your explanation, I'm assuming that you want a gui button that runs a local script after being clicked. After it is clicked for the first time, you then want the local script to run every time the player joins the game again. To do this you will need both a local script inside the gui button, and a server script in ServerScriptService

Try having this inside the local script:

function runScript()
   --enter the local script you wish to run here
end)
script.Parent.MouseButton1Click:Connect(function()
   runScript()
   game.ReplicatedStorage:WaitForChild("onButtonPress"):FireServer("")
end)
local hasPressed = game.ReplicatedStorage:WaitForChild("checkButtonPressed"):InvokeServer("")
if hasPressed then
   runScript()
   script.Parent.Visible = false --remove this if you dont want the button to go invisible if they've already pressed
end

and this in the server script:

local onButtonPress = Instance.new("RemoteEvent")
onButtonPress.Parent = game.ReplicatedStorage
onButtonPress.Name = "onButtonPress"
local checkButtonPress = Instance.new("RemoteFunction")
checkButtonPress.Parent = game.ReplicatedStorage
checkButtonPress.Name = "checkButtonPress"
local ds = game:GetService("DataStoreService"):GetDataStore("HasClicked")

onButtonPress.OnServerEvent:Connect(function(plr)
   ds:SetAsync(tostring(plr.UserId),true)
end)
local function check(plr)
   local hasPressed = ds:GetAsync(tostring(plr.UserId))
   return hasPressed
end
checkButtonPress.OnServerInvoke = check

This may have some typos, because believe it or not I'm on tablet, but hopefully it will give an outline of how it would work.

0
you are amazing but you didnt have to write that script but i happy thank you tykoone -8 — 6y
0
so of im right server script goes serverscriptstorage and i need remoteevent where same place tykoone -8 — 6y
0
i didnt understand what scrip to run? tykoone -8 — 6y
Ad

Answer this question