Download this kit:
Add Module under Script Game Logic
DoorModule
KeyModule
RoundModule
EventHandling
StunScript
-- Piggy "Stun" Script
-- Description: This script stuns the Piggy for 20 seconds. Runs when the Stun RemoteEvent is fired from the client.
-- Creator: AlvinBlox (Alvin_Blox)
-- Created: 22/04/2020 20:16 GMT
-- This code has been distributed to Premium Channel Members of the AlvinBlox YouTube Channel ONLY (https://www.youtube.com/alvinblox)
-- Do not redistribute.
local debounce = false
game.ReplicatedStorage.Stun.OnServerEvent:Connect(function(plr,target)
if target then
if target:FindFirstAncestorOfClass("Model") then
-- Check to see if clicked model is a real player
local pig = game.Players:GetPlayerFromCharacter(target:FindFirstAncestorOfClass("Model"))
if pig then
if pig:FindFirstChild("Piggy") then -- Check to see if it is actually Piggy or just another contestant
if not debounce then
local stunTag = Instance.new("BoolValue") -- Add stun tag so that we can check in other scripts such as Piggy Bat script whether Piggy is stunned or not
stunTag.Name = "Stunned"
stunTag.Parent = pig
if pig.Character:FindFirstChild("Head") then
-- Add confusion sparkles to show Piggy is stunned
local Sparkles = Instance.new("Sparkles")
Sparkles.Parent = pig.Character:FindFirstChild("Head")
Sparkles.SparkleColor = Color3.fromRGB(255,255,255)
end
-- Announce to all players in GUI that Piggy is stunned
game.ReplicatedStorage.Announcement:FireAllClients("Piggy is gone for 20 seconds")
-- Enable debounce so stun effect cannot be applied again for 20 seconds
debounce = true
-- Freeze pig by setting walkspeed to 0
pig.Character.Humanoid.WalkSpeed = 0
wait(20) -- wait 20 sec before enabling walkspeed again to 14 and then setting debounce to false so
-- that the piggy can be stunned again
pig.Character.Humanoid.WalkSpeed = 14
debounce = false
-- At the end of the debounce, remove sparkles
if pig.Character then
if pig.Character:FindFirstChild("Head"):FindFirstChild("Sparkles") then
pig.Character:FindFirstChild("Head"):FindFirstChild("Sparkles"):Destroy()
end
end
pig:FindFirstChild("Stunned"):Destroy() -- Delete stunned tag so we can tell from other scripts that the
-- piggy is no longer stunned.
end
end
end
end
end
end)
Game Logic
local Round = require(script.RounModule)
local Door = require(script.DoorModule)
local Status = game.ReplicatedStorage:WaitForChild("Status")
while wait() do --new press tab (episode-4 (16:minutes))
repeat
local availablePlayers = {}
for i, plr in pairs(game.Players:GetPlayers()) do
if not plr:FindFirstChild("InMenu") then
table.insert(availablePlayers,plr)
end
end
Status.Value = "2 'Ready' players Needed("..#availablePlayers.."/2)"
wait(2)
until #availablePlayers >= 2
Round.Intermission(5) -- he changed it into 5 seconds just watch carefully
local chosenChapter = Round.SelectChapter() --this is the map currently in the chapters folder
local clonedChapter = chosenChapter:Clone()
clonedChapter.Name = "Map"
clonedChapter.Parent = game.Workspace
wait(2)--neww
if clonedChapter:FindFirstChild("Doors") then
Door.ActivateDoors(clonedChapter.Doors)
else
warn("fatal error: you forgot to add the doors folder to your map")
end
local contestants = {}
for i, v in pairs(game.Players:GetPlayers()) do
if not v:FindFirstChild("InMenu") then
table.insert(contestants,v)
end
end
--playr names will display game.players.geethapakala,
local chosenPiggy = Round.ChoosePiggy(contestants)
for i, v in pairs(contestants) do
if v == chosenPiggy then
table.remove(contestants,i)
end
end
wait(2)
Round.DressPiggy(chosenPiggy)
Round.TeleportPiggy(chosenPiggy)
if clonedChapter:FindFirstChild("PlayerSpawns") then
Round.TeleportPlayers(contestants ,clonedChapter.PlayerSpawns:GetChildren())
else
warn("Fatal Error: you didn't add a PLayerSpawns folder into your Map")
end
Round.InsertTag(contestants,"Contestant")
Round.InsertTag({chosenPiggy},"Piggy")
Round.StartRound(600, chosenPiggy,clonedChapter)
contestants = {}
for i, v in pairs(game.Players:GetPlayers()) do
if not v:FindFirstChild("InMenu") then
table.insert(contestants,v)
end
end
if game.Workspace.Lobby:FindFirstChild("Spawns") then
Round.TeleportPlayers(contestants , game.Workspace.Lobby.Spawns:GetChildren())
else
warn("Fatal Error: you have not added a spawns folder into your Lobby with the SpawnLocations inside.please do this to make the script work")
end
clonedChapter:Destroy()
Round.RemoveTags()
wait(2)
end
DoorModule
local module = {}
local tweenService = game:GetService("TweenService")
-- swing the door by `angle` degrees
function module.swingDoor(angle,door)
-- locate the hinge on the door
local hingeBefore = door.CFrame * CFrame.new(-2.5, 0, 0)
-- relative to theA hinge, where is the door?
local relative = hingeBefore:toObjectSpace(door.CFrame)
-- twist the hinge
-- CONVERT angle *from* degrees *to* radians here
local hingeAfter = hingeBefore * CFrame.Angles(0, math.rad(angle), 0)
-- re-attach the door to the new "hinge"
local tweenProperties = TweenInfo.new(0.2) -- Time
local result = {CFrame = hingeAfter:toWorldSpace(relative)}
door.CanCollide = false
local tween = tweenService:Create(door,tweenProperties,result)
tween:Play()
wait(0.2)
door.CanCollide = true
end
function module.ActivateDoors(doorFolder)
for _, door in pairs(doorFolder:GetChildren()) do
if door:FindFirstChild("Key") then
door.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Key") then
if door.Key.Value == hit.Parent.Name then
if door.Name == "ExitDoor" then
if door.Generator.On.Value == true and not door:FindFirstChild("WoodBlock") then
door.Padlock.Anchored = false
wait(1)
door.Transparency = 1
door.CanCollide = false
door.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player:FindFirstChild("Contestant") and not player:FindFirstChild("Escaped") then
local Escaped = Instance.new("BoolValue")
Escaped.Name = "Escaped"
Escaped.Parent = player
game.ReplicatedStorage.Announcement:FireClient(player,"You Escaped")
end
end
end)
end
else
door.Padlock.Anchored = false
wait(0.5)
door:Destroy()
end
end
end
end)
else
if not door:FindFirstChild("ClickDetector") then local cd = Instance.new("ClickDetector") cd.Parent = door end
local debounce = false
door:FindFirstChild("ClickDetector").MouseClick:Connect(function(player)
if door.Name == "Door" then
if not debounce then
debounce = true
local angle
if door:FindFirstChild("Open") then
angle = -90
door.Open:Destroy()
else
angle = 90
local openVal = Instance.new("StringValue")
openVal.Name = "Open"
openVal.Parent = door
end
module.swingDoor(angle,door)
wait(.001)
print("Door swung!")
wait(1)
debounce = false
end
end
end)
end
end
end
return module
KeyModule
RoundModule