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

How to get a simulator shop working on touch?

ME and my friend made a simulator and we have made a proper sell button and shop button and the GUIs, but the shop GUI does not come up when touched here is the code so you can take a look at it:

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

2 comments

0

That should work tbh

0

yeah actually that should work

1 answer

✓ Accepted answer

Hey there,

First off it's important to keep in mind that if you have multiple parts that can be touched this won't work. You should add an onTouched script into the part itsself if this is the case.

Second off, you can't make a gui visible from the server, you should try to clone the gui into the playerGui. This, in turn, is something you can do with the GetPlayerFromCharacter() command. In the end your script should look something like this (although you may need to edit it a bit).

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)
			

If this helped, please accept it as your answer. If it didn't - feel free to ask away! ^^

2 comments

0

OK so I am confused I need to make an on-touched script or is this the on-touched script and I can keep the old script. And also, where should I put these script under(The part?, The StarterGUI?)

0

The script I posted should work as an onTouched script. You may need to edit some variables or strings, though. I would place the script inside the part. You should place the Gui in a folder named "Gui" in the ReplicatedStorage.

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