Hey! I tried to make some kind of tutorial gui for new player in my game. The gui looks like this.
What I want is to make the gui disappear forever when player clicked both buttons. This means it will not show anymore even though player rejoin or reset. Any idea how to make this?
Yep! That’s really easy. Just put this script in both of them:
local Frame = --Path to the Frame which the buttons are in
script.Parent.Mouse1ButtonClick:Connect(function()
Frame.Visible = false
Tell me if it works, and if it doesn’t I’ll look for any spelling mistakes
The script above will only make it so it disappears when the button is pressed. About the rest, idk if it works, but follow @msix29 's instructions. Have a good day!!
Thanks for the help but that’s not exactly what I meant, I want so that gui is gone forever when player clicked it. Your script will just make the gui not visible for a single game/server. So when player rejoined, it will showed up again.
that seems good, I’ll try that. Also how to use datastore to save the bool value? can you give me references to that topic because I’m still confused about datastore?
Im not entirely sure how datastores work, but you could probably store a bool value that detects true or false if the player has already completed / closed the button, leaving as true = frame:destroy()
I cannot elaborate any more on this as i have not tested or used datastores, ever, im just making a suggestion from what ive heard about it.
you can great like a separate screengui from it and then destory the gui when they press either of the buttons after that turn ResetOnSpawn in the screengui off so that it doesn’t come up when they reset
ok so I created a datastore script for that but I guess it does not saves the boolvalue.
Trigger (a localscript inside the gui to change the boolvalue's value)
local yes = script.Parent.Yes
local no = script.Parent.No
local TutorialMain = script.Parent.Parent
local bool = game:GetService("Players").LocalPlayer:WaitForChild("Values"):WaitForChild("Tutorial")
no.MouseButton1Click:Connect(function()
bool.Value = true
end)
yes.MouseButton1Click:Connect(function()
bool.Value = true
print("teleporting")
end)
bool.Changed:Connect(function()
if bool.Value == true then
TutorialMain:Destroy()
end
end)
Datastore server script to save the bool's value
local tutorframe = script.Parent.Parent
local datastore = game:GetService("DataStoreService")
local ds = datastore:GetDataStore("datatest")
game.Players.PlayerAdded:Connect(function(plr)
local values = plr:WaitForChild("Values")
local tutorbool = Instance.new("BoolValue", values)
tutorbool.Name = "Tutorial"
local dataofuser = ds:GetAsync(plr.UserId)
if dataofuser ~= nil then
tutorbool.Value = ds[1]
else
tutorbool.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {}
table.insert(datasave, plr:WaitForChild("Values"):WaitForChild("Tutorial").Value)
local success,response = pcall(function()
ds:GetAsync(plr.UserId,datasave)
end)
if success then
print("Tutorial closed")
else
warn(response)
end
end)
The local script (Trigger) works perfectly, it changes the bool’s value to true and destroys the gui, but the server script don’t save the bool’s value when I rejoined. Also there’s no errors too
why are you using default datastore, you should be using something like profileservice, and datastore2 shouldnt be used due to it being deprecated.
and #2 why is the value you’re saving a bool value? all you have to do is save a bool in a table, no need to save the value from an instance.
You must make the LocalScript contact with the ServerScript using a RemoteEvent. Have a function in the ServerScript listen to the RE’s OnClientEvent(plr, other stuff you want to send), and then FireServer() using the LocalScript.
Explorer:
ReplicatedFirst
- OneTimeGUI <- a RemoteEvent
ServerScriptService
- OneTimeGUIScript <- a ServerScript
-- Server Script
local One_Time_GUI = game:GetService("ReplicatedFirst").OneTimeGUI
-- ... your other DataStore stuff
One_Time_GUI.OnServerEvent:Connect(function(Player, _)
-- ... your DataStore logic
end)
-- Local Script
local One_Time_GUI = game:GetService("ReplicatedFirst").OneTimeGUI
-- ... your GUI stuff
script.Parent.Mouse1ButtonClick:Connect(function()
-- ... your other GUI logic, and then...
One_Time_GUI:FireServer()
end