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

How to get a simulator shop working on touch?

Asked by
zapzser -3
4 years ago

My simulator shop is still not working even after I asked a question they told me to add an ontouched script to add on to my original script but it is not pulling up the GUI when we load in.

Ontouched Script :

local taken = false

script.Parent.Touched:Connect(function(hit) if hit then

if part.Parent:FindFirstChild("Humanoid") then local plr = players:GetPlayerFromCharacter(part.Parent) if taken == false then taken = true game.ReplicatedStorage.Gui:FindFirstChild("Shop"):Clone().Parent = plr.PlayerGui end end end)

Original Script :

game.Workspace.ShopPart.Touched:Connect(function(hit) if hit then script.Parent.Shop.Frame.Visible = true end end)

0
Format your code clicking on the small lua icon at the top of the text box. User#32819 0 — 4y
0
Can you show us the full script with codeblocks and variables? Official_DuckyYT 55 — 4y
0
What do you mean? zapzser -3 — 4y
0
Here is another script zapzser -3 — 4y
View all comments (2 more)
0
here i posted the answer RealJefff2000 68 — 4y
0
Make sure the frame is in a ScreenGui and if you do, check if the "Enabled" property of the ScreenGui is checked. User#32819 0 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I see you're using arguments that we'rent defined before. Just like you made the argument of the touched event "hit" and then used "part.Parent". So here would be the script with correct arguments:

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
                taken = false
                end
            end
        end)
0
so where should i put the gui part zapzser -3 — 4y
0
still doesnt work zapzser -3 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

It doesn't work because you are refering to different things.

script.Parent.Touched:Connect(function(hit)
if hit then

Here you used hit to find the player.

if part.Parent:FindFirstChild("Humanoid") then
local plr = players:GetPlayerFromCharacter(part.Parent)
if taken == false then taken = true game.ReplicatedStorage.Gui:FindFirstChild("Shop"):Clone().Parent = plr.PlayerGui end end end)

But then you used part to refer to the player. Th game doesn't know what part is so your script won't work. You should turn part into hit. The rest seems fine.

0
It still doesnt work zapzser -3 — 4y
0
it doesn't work because you forgot to write game.Players RealJefff2000 68 — 4y
Log in to vote
0
Answered by
goodlead -62
4 years ago

Well... hello sir, here, I think this can help sir..............

local part = script.Parent

part.Touched:Connect(function(hit) 
     local player = GetPlayerFromCharacter(hit.Parent)
     player.PlayerGui.ScreenGui.frame.Visible = true
end)
0
your'e wrong because you should write game.Players:GetPlayerFromCharacter RealJefff2000 68 — 4y

Answer this question