Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to script a simulator shop on touch?

Asked by
zapzser -3
4 years ago

I have tried many other codes others have offered me but non have worked for an ontouched shop. This is my script:

01local taken = false
02 
03script.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)

1 answer

Log in to vote
0
Answered by 4 years ago

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.
2game.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
5end)

This would be the most simple way to do that, but there are more advanced ways that you can do it too!

0
It is still not working zapzser -3 — 4y
Ad

Answer this question