how can i make it so that the seeker is inside a transparent blue ice block when they are frozen during hiding time and it breaks after the time is over.
this is my game loop script:
-- Declared Variables
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local IntermissionTime = 5
local RoundTime = 15
local HidingTime = 5
local MinPlayers = 1
local voteTime = 5
-- Remote Events and Functions
local VotingEvent = ReplicatedStorage:WaitForChild("Voting")
local UpdateVotes = ReplicatedStorage:WaitForChild("UpdateVotes")
local SeekersList = ReplicatedStorage:WaitForChild("SeekersList")
local RoleAnnouncement = ReplicatedStorage:WaitForChild("RoleAnnouncement")
local RoundEnded = ReplicatedStorage:WaitForChild("RoundEnded")
-- Declared Functions
local function TeleportPlayers(cframe) -- Teleport all players to a given CFrame
local players = Players:GetPlayers()
for i, player in players do
if player.Character then
player.Character:PivotTo(cframe)
end
end
end
local function Countdown(duration) -- Countdown for a given duration variable
for i = duration, 1, -1 do
workspace:SetAttribute("Clock", i)
task.wait(1)
end
end
local function Intermission()
print("Intermission")
workspace:SetAttribute("Status", "Intermission")
if workspace:FindFirstChild("IntermissionArea") and workspace.IntermissionArea:FindFirstChild("SpawnLocation") then
TeleportPlayers(workspace.IntermissionArea.SpawnLocation.CFrame * CFrame.new(0, 2, 0))
else
warn("Could not find IntermissionArea and/or its SpawnLocation.")
end
Countdown(IntermissionTime)
end
local function RunGame(map) -- Run the game with a given map
print("Game Begins")
if map:FindFirstChild("Spawn") then
TeleportPlayers(map.Spawn.CFrame)
else
warn("Selected map is missing a 'Spawn' location.")
end
code
-- Role assignment
local players = Players:GetPlayers()
if #players < 1 then return end
local seekerIndex = math.random(1, #players)
local seeker = players[seekerIndex]
local roles = {}
local seekers = {}
for _, player in players do
local isSeeker = player == seeker
roles[player] = if isSeeker then "Seeker" else "Hider"
if isSeeker then
table.insert(seekers, player)
player.Team = Teams.Seeker
else
player.Team = Teams.Hider
end
end
-- Freeze the seeker
if seeker and seeker.Character then
local humanoid = seeker.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
-- Freeze player
local originalWalkSpeed = humanoid.WalkSpeed
local originalJumpPower = humanoid.JumpPower
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
task.delay(HidingTime, function()
-- Check if the character and humanoid still exist before unfreezing
if seeker.Character and seeker.Character:FindFirstChildOfClass("Humanoid") then
local currentHumanoid = seeker.Character:FindFirstChildOfClass("Humanoid")
currentHumanoid.WalkSpeed = originalWalkSpeed
currentHumanoid.JumpPower = originalJumpPower
end
end)
end
end
-- Send role info to clients
for player, role in roles do
RoleAnnouncement:FireClient(player, role)
end
-- Send seekers list to all clients
SeekersList:FireAllClients(seekers)
workspace:SetAttribute("Status", "Time To Hide")
Countdown(HidingTime)
workspace:SetAttribute("Status", "Time remaining")
Countdown(RoundTime)
task.wait(1)
map:Destroy()
end
-- Add round end cleanup
local function EndRound()
print("Round Ended")
-- Clear teams
for _, player in Players:GetPlayers() do
player.Team = nil
end
code
-- Notify clients
RoundEnded:FireAllClients()
end
local function SetupTeams()
-- Create Seeker Team (Red)
local seekerTeam = Teams:FindFirstChild("Seeker")
if not seekerTeam then
seekerTeam = Instance.new("Team")
seekerTeam.Name = "Seeker"
seekerTeam.TeamColor = BrickColor.new("Bright red")
seekerTeam.AutoAssignable = false
seekerTeam.Parent = Teams
end
code
-- Create Hider Team (Blue)
local hiderTeam = Teams:FindFirstChild("Hider")
if not hiderTeam then
hiderTeam = Instance.new("Team")
hiderTeam.Name = "Hider"
hiderTeam.TeamColor = BrickColor.new("Bright blue")
hiderTeam.AutoAssignable = false
hiderTeam.Parent = Teams
end
end
-- Game Loop
while true do
if #Players:GetPlayers() >= MinPlayers then
Intermission()
SetupTeams()
workspace:SetAttribute("Status", "Loading Map...")
print("New Game!")
code
-- Map voting
local mapsFolder = ServerStorage:FindFirstChild("Maps")
if not mapsFolder or #mapsFolder:GetChildren() < 3 then
warn("Not enough maps in ServerStorage.Maps to start a vote. Need at least 3. Skipping round.")
task.wait(5)
continue -- Skips the rest of the loop and starts over
end
local mapVotes = {}
local plrVotes = {}
local selectedMaps = {}
local currentMaps = mapsFolder:GetChildren()
for i = 1, 3 do
local randomIndex = math.random(#currentMaps)
local newMap = currentMaps[randomIndex]
table.remove(currentMaps, randomIndex)
table.insert(selectedMaps, {
Name = newMap.Name,
Img = newMap:GetAttribute("MapImg")
})
mapVotes[newMap.Name] = 0
end
VotingEvent:FireAllClients(selectedMaps, voteTime)
UpdateVotes.OnServerInvoke = function(player, vote)
if vote then
local mapModel = mapsFolder:FindFirstChild(vote)
if not mapModel or mapVotes[mapModel.Name] == nil then
warn(tostring(vote).. " is not a votable map")
return mapVotes
end
local playerVote = plrVotes[player.UserId]
if playerVote then
mapVotes[playerVote] -= 1
end
plrVotes[player.UserId] = vote
mapVotes[vote] += 1
end
return mapVotes
end
task.wait(voteTime)
VotingEvent:FireAllClients(nil)
UpdateVotes.OnServerInvoke = nil
local chosenMap = nil
local highestVotes = -1
for name, votes in mapVotes do
if votes > highestVotes then
chosenMap = mapsFolder[name]
highestVotes = votes
end
end
if not chosenMap then
print("No map won the vote. Picking a random map from the selection.")
local randomMapInfo = selectedMaps[math.random(#selectedMaps)]
chosenMap = mapsFolder[randomMapInfo.Name]
end
print(chosenMap.Name, "was picked")
task.wait(1)
local newMap = chosenMap:Clone()
newMap.Parent = workspace
RunGame(newMap)
EndRound()
else
print("Waiting for players...")
workspace:SetAttribute("Status", "Waiting for players...")
task.wait(1)
end
end
Assistant
To implement the transparent blue ice block that surrounds the Seeker during Hiding Time, and then breaks after the time is over, follow these steps:
✅ 1. Create the Ice Block Template (on ServerStorage)
In ServerStorage, create a model called IceBlock with:
A single Part named IcePart
Size: 5, 8, 5 (or adjust to fit player)
Transparency: 0.3
Color: Medium blue
Material: Neon or Glass (for visual effect)
Anchored: false
CanCollide: false
You can also add a ParticleEmitter for frosty visuals if you want.
This will be the "ice prison" cloned and placed around the seeker when frozen.
✅ 2. Modify Your RunGame() Function
Add this code right after you freeze the Seeker in your RunGame(map) function:
lua
-- Freeze the seeker and put them in an ice block
if seeker and seeker.Character then
local humanoid = seeker.Character:FindFirstChildOfClass("Humanoid")
local rootPart = seeker.Character:FindFirstChild("HumanoidRootPart")
if humanoid and rootPart then
-- Save original movement stats
local originalWalkSpeed = humanoid.WalkSpeed
local originalJumpPower = humanoid.JumpPower
-- Freeze player
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
-- Clone the ice block from ServerStorage
local iceBlock = ServerStorage.IceBlock:FindFirstChild("IcePart"):Clone()
if iceBlock then
iceBlock.Anchored = false
iceBlock.CanCollide = false
iceBlock.Parent = workspace
-- Position the ice block around the seeker's root part
iceBlock.CFrame = rootPart.CFrame * CFrame.new(0, 0, 0)
-- Attach it to seeker so it follows them
local weld = Instance.new("WeldConstraint")
weld.Part0 = iceBlock
weld.Part1 = rootPart
weld.Parent = iceBlock
-- Break the ice after hiding time ends
task.delay(HidingTime, function()
if iceBlock and iceBlock.Parent then
-- Optional: Play breaking animation or effects here
-- Remove weld and destroy block
weld:Destroy()
iceBlock:Destroy()
end
-- Unfreeze player
if seeker.Character and seeker.Character:FindFirstChildOfClass("Humanoid") then
local currentHumanoid = seeker.Character:FindFirstChildOfClass("Humanoid")
currentHumanoid.WalkSpeed = originalWalkSpeed
currentHumanoid.JumpPower = originalJumpPower
end
end)
end
end
end
✅ 3. Optional: Add Breaking Effect (Client or Server)
If you want the ice to shatter dramatically, you could:
Use a decal texture change
Create multiple small ice shards and apply BodyVelocity
Or use a particle explosion
Example of a simple shatter:
lua
-- Inside the task.delay block, before iceBlock:Destroy()
-- Shatter effect
local debris = Instance.new("Part")
debris.Shape = Enum.PartType.Block
debris.Size = iceBlock.Size
debris.CFrame = iceBlock.CFrame
debris.Anchored = false
debris.Material = Enum.Material.Ice
debris.BrickColor = iceBlock.BrickColor
debris.Transparency = iceBlock.Transparency
debris.Velocity = Vector3.new(math.random(-10,10), math.random(5,10), math.random(-10,10))
debris.Parent = workspace
-- Destroy after 3 seconds
task.delay(3, function()
if debris.Parent then debris:Destroy() end
end)
Repeat this several times for more pieces.
✅ 4. Make Sure You Have This in ReplicatedStorage
Ensure you have these RemoteEvents already created in ReplicatedStorage:
Voting
UpdateVotes
SeekersList
RoleAnnouncement
RoundEnded
And this one added:
IceBlock in ServerStorage
✅ Summary of What This Does:
Feature
Description
Freeze Movement
Stops the seeker from moving during HidingTime
Ice Block
Surrounds the seeker in a visible transparent blue block
Follows Player
Uses WeldConstraint to stay on the seeker
Breaks After Time
Destroys the block and unfreezes the seeker after HidingTime
Let me know if you'd like to add sound effects, camera shake, or UI notifications for when the ice breaks!