This script is supposed to enable a gui and anchor all players for 60 seconds when an event is fired, instead it does nothing.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Freeze = ReplicatedStorage:WaitForChild("Freeze")
local Gui = script.Parent
local playerService = game:GetService("Players")
playerService.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
plr.CharacterAdded:Connect(function(char)
Freeze.OnServerEvent:Connect(function()
if not Gui.Enabled then
Gui.Enabled = true
char.HumanoidRootPart.Anchored = true
end
wait(60)
if Gui.Enabled then
Gui.Enabled = false
char.HumanoidRootPart.Anchored = false
end
end)
end)
end)
if Gui.Enabled == false then
Gui.Enabled = true
char.HumanoidRootPart.Anchored = true
end
wait(60)
if Gui.Enabled == true then
Gui.Enabled = false
char.HumanoidRootPart.Anchored = false
I thought I’d read in the forums here that you have to continuously change a Humanoid’s properties every frame (or heartbeat or something) because the properties will revert back to normal in the next frame.
Things like Transparency & Anchored were mentioned in posts that I’ve read.
I might be completely off base here, but try searching the forum for similar issues with changing a Humanoid’s properties.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Freeze = ReplicatedStorage:WaitForChild("Freeze")
local Gui = script.Parent
local playerService = game:GetService("Players")
Freeze.OnServerEvent:Connect(function(plr, GuiEnabled)
local char = plr.Character
if not GuiEnabled then
GuiEnabled = true
Freeze:FireClient(plr, "EnableGui")
char.HumanoidRootPart.Anchored = true
end
wait(60)
if GuiEnabled then
Freeze:FireClient(plr, "DisableGui")
char.HumanoidRootPart.Anchored = false
end
end)
The first time you fire to the server, you must add a parameter, that indicated whether the Gui is Enabled or not. You must also set up an OnClientEvent event to enable/disabled the Gui from the client.
Yeah, but there’s no reason to do such a thing, and most people like using things like not instead of == false since it has less characters and requires minimal effort.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Freeze = ReplicatedStorage:WaitForChild("Freeze")
Freeze.OnServerEvent:Connect(function(Player)
local Players = game:GetService("Players")
for i,Plr in pairs(Players:GetPlayers()) do
local Character = Plr.Character
local PlrGUI = Player.PlayerGui
if not PlrGUI["YourScreenGuiName"].Enabled then
PlrGUI["YourScreenGuiName"].Enabled = true
Character.HumanoidRootPart.Anchored = true
end
task.wait(60)
if PlrGUI["YourScreenGuiName"].Enabled then
PlrGUI["YourScreenGuiName"].Enabled = false
Character.HumanoidRootPart.Anchored = false
end
end
end)