Firstly I should say, this is part of a obby game I’m trying to complete, and this feature is the only one I’m really stuck on.
I’m trying to make the Gui Button become visible once a player has touched a part, and the game remembers that it has been touched so it stays that way for the player, so in a way it is “Unlocked”.
I am new to scripting in general so I’m not sure if I’m suppose to use DataStores since that is the only reasonable sounding thing to use or if not something else I am not aware of.
I’ve tried connecting it to a badge through the help of the Coding Assistant but it hasn’t been a big help so far, meaning it did not work.
Here’s an image of the layout for the gui.
All the Images have the same stuff, via. UiCorner, TextButton, and LocalScript.
I want to make the TextButton visible when Obby part has been touched, and then remembered so the player doesn’t have to touch the part again to click the button/make the button visible.
And here’s the code for the LocalScript, which teleports the player when part is touched:
local part = script.Parent.Parent.Parent.Parent.TpParts.Obby
--When clicked, teleports to plr to part.
button.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = part.CFrame
end)
I’m unsure where to start or what I should do first, any help would be appreciated at this point, if you need any more pictures, code I’m using, or whatnot, feel free to ask.
It sounds to me like you’re going to need to use some datastores if you want the game to remember which Guis was visible in a previous play session. Data stores are often made out to be extremely difficult and complicated to new scripters, but they’re really pretty simple. The coding assistant actually has the most basic use that I can find if you input “Example of a basic datastore.” You can look up a basic tutorial on You-Tube or use this tutorial on the Forum:
Documentation is always useful as well:
If you still don’t understand, you can dm me and I’ll try to help.
A couple other things I noticed
Correct me if I’m wrong, but it appears that you have a duplicate Local Script in each Image Label that contains the same code. This probably works, but it’s bad practice. Instead, create a single local script parented to “TeleportButtons” and loop through each of the ImageLabels and set the Moust1 event. So your code would look something like this:
local part = script.Parent.Parent.TpParts.Obby-- double check this if the script is parented to TelepottButtons
for _, label in pairs(script.Parent:GetChildren()) do
label.TextButton.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = part.CFrame
end)
end
That way you only need one script that handles all the buttons.