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
script.Parent.Touched:Connect(function(hit)
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)
end
d = false
end)
I can show the “No” button script as well if you need me to. Thanks in advance!
When you pressed the “No” button, the changes it made to the GUI only shows to the client, not the server. To fix this, I’d suggest making this script client-sided.
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
script.Parent.Touched:Connect(function(hit)
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
end
end
end)
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?
I tested DataErased code, and it worked perfectly fine, i assume you, @iy_uhn, will mark his post as solved, if it didn’t solve for you, then i guess i can’t do anything anymore.