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
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.