Advertisement
JJBloxxer

Touch Part to Open Gui Roblox

May 31st, 2020
2,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. -- Server Script
  2. local replicatedStorage = game:GetService('ReplicatedStorage');
  3. local remoteEvent = replicatedStorage:WaitForChild('RE');
  4.  
  5. local guiTogglePart = script.Parent;
  6.  
  7. guiTogglePart.Touched:Connect(function(touchedObject)
  8.     local player = game.Players:GetPlayerFromCharacter(touchedObject.Parent);
  9.     if player then
  10.         remoteEvent:FireClient(player);
  11.     end
  12. end)
  13.  
  14. -- Client Script
  15. local replicatedStorage = game:GetService('ReplicatedStorage');
  16. local remoteEvent = replicatedStorage:WaitForChild('RE');
  17.  
  18. local frame = script.Parent;
  19. local closeButton = frame.CloseButton;
  20.  
  21. local isOpen = false;
  22.  
  23. remoteEvent.OnClientEvent:Connect(function()
  24.     if not isOpen then
  25.         isOpen = true;
  26.         frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), 'Out', 'Sine', 0.2, true);
  27.     end
  28. end)
  29.  
  30. closeButton.MouseButton1Click:Connect(function()
  31.     if isOpen then
  32.         isOpen = false;
  33.         frame:TweenPosition(UDim2.new(0.5, 0, 1.5, 0), 'Out', 'Sine', 0.2, true);
  34.     end
  35. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement