-- I made this script, it is a server script -- It does NOT work, I did many attempts -- I want the gui only to appear for the player that touched the part -- I do not know if this should be a localscript or serverscript -- Please help if script.Parent.Touched == true then script.Parent.keyGui:DuplicateIntoPlayerGui() end if script.Parent.Touched == false then while true do(nothing) game.Nothing = true end
You can use touched and touch ended events to trigger GUIs Example:
-- LocalScript local part = script.Parent local gui = game:GetStorage("ReplicatedStorage"):WaitForChild("TouchGui") local last = nil local function Touch(tpart) if tpart then local character = part:FindFirstAncestorWhichIsA("Model") if character then local player = game:GetService("Players"):GetPlayerFromCharacter(character) if player and gui then local exists = player:WaitForChild("PlayerGui"):FindFirstChild(gui.Name) if notexists then local clone = gui:Clone() clone.Parent = player:WaitForChild("PlayerGui") end last = tpart end end end end local function UnTouch(tpart) if tpart then if tpart == last then local character = part:FindFirstAncestorWhichIsA("Model") if character then local player = game:GetService("Players"):GetPlayerFromCharacter(character) if player and gui then local exists = player:WaitForChild("PlayerGui"):FindFirstChild(gui.Name) if exists then exists:Destroy() end last = nil end end end end end part.Touched:Connect(Touched) part.TouchEnded:Connect(UnTouched)