Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get a simulator shop working on touch?

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)

6 comments

0

Format your code clicking on the small lua icon at the top of the text box.

0

Can you show us the full script with codeblocks and variables?

0

What do you mean?

0

Here is another script

0

here i posted the answer

0

Make sure the frame is in a ScreenGui and if you do, check if the "Enabled" property of the ScreenGui is checked.

3 answers

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)

2 comments

0

so where should i put the gui part

0

still doesnt work

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.

2 comments

0

It still doesnt work

0

it doesn't work because you forgot to write game.Players

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)

1 comment

0

your'e wrong because you should write game.Players:GetPlayerFromCharacter

This discussion is preserved as it was. New answers, comments, and votes are closed.