I am trying to make everything freeze when I press F. This so far has worked but I have encountered another problem. The baseplate unanchores even though I have checked if the part’s name is not “Baseplate”.
Here’s the issue in the video:
Here’s the script:
local remote = game:GetService("ReplicatedStorage"):WaitForChild("ZaWarudo")
local CD = 12
remote.OnServerEvent:Connect(function(player,tab)
warn("Recieved.")
for _,v in pairs(workspace:GetDescendants()) do
if v:IsA("BasePart") and (v.Name ~= "hasoco" or v.Name ~= "Baseplate" or v.Name ~= "SpawnLocation" or v.Name ~= "Player1") then
v.Anchored = true
task.wait(CD)
v.Anchored = false
end
end
end)
I was going to tell you something, but first, let me ask. What do you want it to do exactly? Freeze players? Floating parts? If so, do you want them to unfreeze after 12 seconds? Do the parts become unanchored immediately?
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)
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)
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.
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)