I've been trying several methods to for a pop up gui but for some reason I cant seem to get anything to work. I would be really thankful if anyone can tell me how to do this properly. Thanks! (Btw I do have a text button that currently opens the gui idk if that would make a difference or not and the brick is in workspace)
http://imgur.com/a/A1kOew3 This is what the Gui looks like. The "TextButton" is the button that currently opens MainFrame
What I've tried doing
game.Players.PlayerAdded:Connect(function(plr) script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then plr.PlayerGui.GunShop.MainFrame.Visible = true end end) end)
..
local Part = script.Parent Part.Touched:connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local Player = game.Players:GetPlayerFromCharacter(HIT.Parent) Player.PlayerGui.GunShop.MainFrame.Visible = true end end)
I tried some variants of these two and also some random guesses that I didn't really expect to work :/
So you can achieve this with the Instance.Touched event, however, the server cannot access individual player's guis from a server script, so that must be done locally. Luckily local scripts can detect Touched events of items in workspace, so that helps you do this without the use of a remote event/ remote function.
The goals of the local script should be to : 1) have a touched event 2) check if a body part of the player is touching the part 3) if so, make a GUI pop up
so, here it is
--it should be a LOCAL SCRIPT (putting this here to avoid confusion) local player = game.Players.LocalPlayer workspace.Part.Touched:Connect(function(hit) if hit and hit.Parent then local plr = game.Player:GetPlayerFromCharacter(hit.Parent) if plr and plr == player then --player.PlayerGui.ScreenGui.Frame.Visible = true player.PlayerGui.ScreenGui.Frame.Visible = not player.PlayerGui.ScreenGui.Frame.Visible end end end)
--it should be a LOCAL SCRIPT (putting this here to avoid confusion) local player = game.Players.LocalPlayer workspace.Part.Touched:Connect(function(hit) if hit:IsDescendantOf(player.Character) --player.PlayerGui.ScreenGui.Frame.Visible = true end end)
I have some code for you: (hopefully it works in a real server)
https://imgur.com/a/EY8VYfJ