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

This code opens when someone else touchs it, please explain how to fix it to me?

This codes opens when someone else steps on the object, please explain to me how to fix it Code:

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

2 answers

✓ Accepted answer
-- Script in ServerScriptService
local guiname="ScreenGui" -- change


local Players=game:GetService"Players"
local function showgui(player,guiname)
player.PlayerGui[guiname].Shop.PetInventory.Visible=true
end
local a;workspace.ShopPart.Touched:Connect(function(part)
if a then return end;a=true
local player=Players:GetPlayerFromCharacter(part.Parent)
	if player then
		pcall(showgui,player,guiname)
	end
wait(1)a=false
end)




1 comment

0

Thanks!

So basically its just getting when its touched and if hit then is just soemthing to check

2 comments

0

im bad at coding, please explain more if you can

0

it just makes a gui visible when somehhing touches it

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