I have tried many other codes others have offered me but non have worked for an ontouched shop. This is my script:
01 | local taken = false |
02 |
03 | script.Parent.Touched:Connect( function (hit) |
04 | if hit then |
05 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
06 | if taken = = false then |
07 | taken = true |
08 | local plr = players:GetPlayerFromCharacter(hit.Parent) |
09 | game.ReplicatedStorage.Gui:FindFirstChild( "Shop" ):Clone().Parent = plr.PlayerGui.Shop.Frame |
10 | taken = false |
11 | end |
12 | end |
13 | end ) |
From what I see, it seems like you're trying to make it so that whenever you touch a certain part, your shop GUI pops up. If you're trying to make this, you don't need this complicated of a script at all. Make a ScreenGui in StarterGui and move your GUI you want to pop up there. In it, you're going to insert a LocalScript. After that, make sure you have a part in the Workspace that you want the player to step on.
All you need to do is:
1 | --this creates an event for when the part is touched and connects it to a function so we can make changes. Change "Part" to whatever your part is named. |
2 | game.Workspace.Part.Touched:Connect( function () |
3 | --This makes the GUI that is the LocalScript's parent's visibility to true. |
4 | script.Parent.Visible = true |
5 | end ) |
This would be the most simple way to do that, but there are more advanced ways that you can do it too!