Freeze players. I want them to unfreeze after 12 seconds.
The video didn’t really help much tbh.
Okay so, I can help ya with that.
You should consider changing the or’s on your script with and since you want the part’s name not to be any of those you’ve list.
Also that would be nice if you have a table containing a blacklist for the parts that should not be anchored, it would look something like this :
local remote = game:GetService("ReplicatedStorage"):WaitForChild("ZaWarudo")
local CD = 12
local blacklist = {
["Baseplate"] = true;
["hasoco"] = true;
["SpawnLocation"] = true;
["Player1"] = true
}
remote.OnServerEvent:Connect(function(player,tab)
warn("Recieved.")
for _,v in pairs(workspace:GetDescendants()) do
if v:IsA("BasePart") and not blacklist[v.Name] then
v.Anchored = true
task.wait(CD)
v.Anchored = false
end
end
end)
That works, but problem is, some parts dont anchor.
If you are trying to freeze only the players you could look only for the players when applying the freeze effect, if that is the case I think this topic could help you.
Instead of that, try this instead. This should hopefully be simple. Sorry. I wish this was like the actual code lines. If you see any errors, just add the ends I forgot ;-;
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("ZaWarudo")
local Characters = nil
local CD = 12
Remote.OnServerEvent:Connect(function(player, tab)
print("Recieved.")
for i, v in pairs(game.Players:GetPlayers()) do
if v.ClassName == "Player" then
Characters = v.Character
if Characters ~= nil then
local BodyParts = Characters:GetChildren()
for i = 1, #BodyParts do
if BodyParts[i].ClassName == "Part" or BodyParts[i].ClassName == "MeshPart" then
local CorrectBodyParts = BodyParts[i]
CorrectBodyParts.Anchored = true
end
end
task.wait(CD)
for i = 1, #BodyParts do
if BodyParts[i].ClassName == "Part" or BodyParts[i].ClassName == "MeshPart" then
local CorrectBodyParts = BodyParts[i]
CorrectBodyParts.Anchored = false
end
end
end
end
end
end)
Only freezes the player that fires the event.
Hmm alright. Let me tweak this then.
Give me five minutes. I’ll make a script and run some tests.
The problem lies within the or’s you have in your script, you see the way “or” works is that if only 1 returns true makes the whole statement true. fix your if statement and your issue should be resolved.
Okay. So this is an important question. Where is your event located? And where is this script located?
The Event is located in ReplicatedStorage and the script is in ServerScriptService
Alright. So, is this a Global Cooldown you want? Or do you want the cooldown to be for the player that fires this event?
Cooldown for the player that fires the event.
Alright. So first, you’ll need to rearrange your event and script locations. I’d make a script that automatically parents these instances. I’ll type you a script for it.
Alright. Here you go. All you have to do is copy and paste this into a script. (“Place this script in the Workspace by the way.”)
local Players = game.Players or game:GetService("Players")
local ReplicatedStorage = game.ReplicatedStorage or game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("ZaWarudo")
Players.PlayerAdded:Connect(function(Player)
local PlayerEvent = Event:Clone()
PlayerEvent.Parent = Player
end)
Still freezes only the player that fires it
No biggy. I’ll make you a local script now for it.
This may take 10 minutes at the most. So check back here in 10 minutes, or whenever you get a notification here.