The problem I have is when I touch a part with a specific name a gui with a frame opens, but when a player touches the block and the frame opens the other players also the gui opens without touching the block.
What I want is for each individual player to be able to see his or her Gui when touching the block.
Here is the local script that I use to open the gui and I want to say that the local script I place it in the screngui not directly in the frame
local part = game.Workspace.TactoPart1
local gui = script.Parent.Frame
part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
gui.Visible = true
end
end)
part.TouchEnded:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
gui.Visible = false
end
end)
just clone it into the players playergui, and when the player stops touching you can just use FindFirstChild to find the ui in player gui (and then destroy it)
local part = game.Workspace.TactoPart1
local guiTemplate = script.Parent.Frame
part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local playerGui = guiTemplate:Clone()
playerGui.Parent = plr.PlayerGui
playerGui.Visible = true
part.TouchEnded:Connect(function(touchEndHit)
local endPlr = game.Players:GetPlayerFromCharacter(touchEndHit.Parent)
if endPlr == plr then
playerGui:Destroy()
end
end)
end
end)