I made a Gui that activates when a part is touched. However, when I close said Gui (using a “No” button), the Gui does not reappear when part is touched again. Here is the script (ServerScript) I’m using:
local d = false
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
d = true
if player and d == true then
local pName = player.Name
local pGui = player.PlayerGui
pGui.GameGui.Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 1, true)
d = false
I can show the “No” button script as well if you need me to. Thanks in advance!
This ^ should most definitely be on the client. Moving it to the client would also allow for smoother effects when tweening. With all that being said, I would also recommend using TweenService to move the Gui.
As far as your current script goes, here’s how I would’ve done it (if it were on the server)
local debounce = false
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(character)
if player and debounce == false then
debounce = true
local playerGui = player.PlayerGui
playerGui.GameGui.Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 1, true)
debounce = false
When I move my script into a LocalScript (changing the “local player” line to game.Players.LocalPlayer) the script does not respond at all. Should I move this LocalScript into ServerScriptService or do something else?