The gui open to everyone in server, no just to the one that tpuch the part
I have been looking for different solutions but doesnt work
Heres the script
script.Parent.Touched:Connect(function(hit)
for i,v in pairs(game.Players:GetPlayers()) do
if v.PlayerGui then
v.PlayerGui.shop.panel.Visible = true
wait(5)
v.PlayerGui.shop.panel.Visible = false
end
end
end)
You use the .Touched event to get the player, which goes as following:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
end
end)
Now, you can easily disable their GUI. You can do this with a RemoteEvent or you can do it server-sided, which I donโt recommend.
Server-sided way:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.shop.panel.Visible = true
wait(5)
player.PlayerGui.shop.panel.Visible = false
end
end)
Iโm not sure if that works, I typed it in a rush. Let me know.
local Players = game:GetService("Players")
local Part = script.Parent
local function Touched(Hit)
local Character = Hit:FindFirstAncestorOfClass("Model")
if Character then
local Player = Players:GetPlayerFromCharacter(Character)
if Player then
local Panel = Player:WaitForChild("PlayerGui"):WaitForChild("shop"):WaitForChild("panel")
Panel.Visible = true
wait(5)
Panel.Visible = false
end
end
end
Part.Touched:Connect(Touched)