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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
-- 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)




0
Thanks! coolperson21216 4 — 3y
Ad
Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago

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

0
im bad at coding, please explain more if you can coolperson21216 4 — 3y
0
it just makes a gui visible when somehhing touches it 3F1VE 257 — 3y

Answer this question