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:

local taken = false

script.Parent.Touched:Connect(function(hit)
    if hit then
        if hit.Parent:FindFirstChild("Humanoid") then
            if taken == false then
                taken = true
                local plr = players:GetPlayerFromCharacter(hit.Parent)
                game.ReplicatedStorage.Gui:FindFirstChild("Shop"):Clone().Parent = plr.PlayerGui.Shop.Frame
                taken = false
                end
            end
        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:

 --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.
game.Workspace.Part.Touched:Connect(function()
    --This makes the GUI that is the LocalScript's parent's visibility to true.
    script.Parent.Visible = true 
end)

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