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
Is it possible to save screen gui>frame>textbutton>localscript?
1 answer
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.
3 comments
you are amazing but you didnt have to write that script but i happy thank you
so of im right server script goes serverscriptstorage and i need remoteevent where same place
i didnt understand what scrip to run?
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
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.
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 :(
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.
thx for giving that link you are the best!