You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
For the shrine model to stop disappearing early and to let the tween complete, hence completing the script -
What is the issue? Include screenshots / videos if possible!
It keeps infinite yielding or attempting to index findfirstchild because the folder keeps on disappearing randomly. It works sometimes but most of the time when the tool is used, the shrine completely disappears nearing the end of it and the script completely breaks. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes, the built in AI beta and my scripter friend. It is a tool and the colorcorrection effect also stays when it breaks
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local CollectionService = game:GetService('CollectionService')
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("ShrineEvent")
local TweenService = game:GetService('TweenService')
local Debris = game:GetService("Debris")
local CollectionService = game:GetService('CollectionService')
local Assets = game:GetService("ReplicatedStorage"):WaitForChild("Assets")
local Setting = require(script:WaitForChild("Setting"))
local rng = math.random
local rad = math.rad
local angle = CFrame.fromEulerAnglesXYZ
Remote.OnServerEvent:Connect(function()
local Player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
if not CollectionService:HasTag(Character,"Attacking") and not CollectionService:HasTag(Character,"MalevolentShrineCD") then
CollectionService:AddTag(Character,"Attacking")
CollectionService:AddTag(Character,"MalevolentShrineCD")
local SavedWalkSpeed = Humanoid.WalkSpeed
local SavedJumpPower = Humanoid.JumpPower
local SavedJumpHeight = Humanoid.JumpHeight
local Cooldown = Setting["Cooldown"]
local Duration = Setting["Duration"]
local HitboxRange = Setting["HitboxRange"]
local VisualRange = Setting["VisualRange"]
local Damage = Setting["Damage"]
local Moveable = Setting["Moveable"]
local SlashPerRound = Setting["SlashPerRound"]
local Rock = Setting["Rock"]
local Overhead = Assets["VFX"]["Part"]["Overhead"]:Clone()
Overhead.Parent = Root
Humanoid.AutoRotate = false
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
Humanoid.JumpHeight = 0
local FXFolder = Instance.new("Folder",workspace)
FXFolder.Name = "MalShrine"
Debris:AddItem(FXFolder,Duration+10)
local RockFolder = Instance.new("Folder",FXFolder)
RockFolder.Name = "Rocks"
local SlashesFolder = Instance.new("Model",FXFolder)
SlashesFolder.Name = "Slashes"
local DestroyedFolder = Instance.new("Folder",FXFolder)
DestroyedFolder.Name = "DestroyedFolder"
local Highlight = Instance.new("Highlight",SlashesFolder)
Highlight.DepthMode = Enum.HighlightDepthMode.Occluded
Highlight.FillColor = Color3.new(0, 0, 0)
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = 0
local Voice = Assets["SFX"]["Voice"]:Clone()
Voice.Parent = Root
Voice.RollOffMaxDistance = VisualRange/2
Voice:Play()
Debris:AddItem(Voice,Voice.TimeLength+0.2)
local Action = Humanoid:LoadAnimation(Assets["Animations"]["Standing"])
Action:Play(0.1,1,1)
Action:GetMarkerReachedSignal("Stop"):Connect(function()
Action:AdjustSpeed(0)
end)
task.spawn(function()
local Hitted = {}
local Hitbox = workspace:GetPartBoundsInBox(Root.CFrame,HitboxRange)
for i,a in pairs(Hitbox) do
if a.Parent:FindFirstChild("Humanoid") and a.Parent:FindFirstChild("HumanoidRootPart") then
local Enemy = a.Parent
local EnemyHumanoid = Enemy:FindFirstChild("Humanoid")
local EnemyRoot = Enemy:FindFirstChild("HumanoidRootPart")
if Hitted[EnemyHumanoid] == nil then
Hitted[EnemyHumanoid] = true
local IsPlayer = game:GetService("Players"):GetPlayerFromCharacter(Enemy)
if IsPlayer then
task.spawn(function()
Remote:FireClient(IsPlayer,"Cutscene",{1,Character})
task.wait(3.25)
Remote:FireClient(IsPlayer,"Cutscene",{2,Character})
end)
end
end
end
end
end)
task.wait(1)
Overhead:Destroy()
Root.Anchored = true
local Shrine = Assets["VFX"]["Shrine"]:Clone()
Shrine.Parent = FXFolder
local Shrine2 = Shrine:WaitForChild("Shrine2", 5) -- Adding a timeout of 5 seconds
if not Shrine2 then
warn("Shrine2 not found within timeout!")
return
end
Shrine2.OST.RollOffMaxDistance = VisualRange / 2
Shrine2.Saw.RollOffMaxDistance = VisualRange / 2
Shrine:SetPrimaryPartCFrame(Root.CFrame * CFrame.new(0, -20, 12))
local Goal = {
CFrame = Root.CFrame * CFrame.new(0,13,12)
}
local Info = TweenInfo.new(2,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Shrine:WaitForChild("Shrine2"),Info,Goal)
Tween:Play()
local Goal = {
CFrame = Root.CFrame * CFrame.new(0,6,0)
}
local Info = TweenInfo.new(2,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Root,Info,Goal)
Tween:Play()
task.wait(2.25)
local Goal = {
FillTransparency = 1,
}
local Info = TweenInfo.new(1,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Shrine.Highlight,Info,Goal)
Tween:Play()
task.wait(0.76)
local Slashing = Instance.new("ColorCorrectionEffect",game.Lighting)
local Goal = {
Brightness = -0.3,
Contrast = 0.2,
TintColor = Color3.fromRGB(255, 181, 181)
}
local Info = TweenInfo.new(1,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Slashing,Info,Goal)
Tween:Play()
Shrine:WaitForChild("Shrine2").OST:Play()
Shrine:WaitForChild("Shrine2").Saw:Play()
local SavedCF = Root.CFrame
if Moveable == true then
Humanoid.WalkSpeed = SavedWalkSpeed
Humanoid.JumpPower = SavedJumpPower
Humanoid.JumpHeight = SavedJumpHeight
Action:Stop()
Root.Anchored = false
Humanoid.AutoRotate = true
end
local Start = tick()
local DestroyedPart = {}
repeat
local Hitted = {}
local Hitbox = workspace:GetPartBoundsInBox(Shrine:WaitForChild("Shrine2").CFrame,HitboxRange)
for i,a in pairs(Hitbox) do
if a.Parent and a.Parent:FindFirstChild("Humanoid") and a.Parent:FindFirstChild("Torso") then
local Enemy = a.Parent
local EnemyHumanoid = Enemy:FindFirstChild("Humanoid")
local EnemyRoot = Enemy:FindFirstChild("Torso")
if Hitted[EnemyHumanoid] == nil then
Hitted[EnemyHumanoid] = true
if Enemy ~= Character then
EnemyHumanoid:TakeDamage(Damage)
end
local IsPlayer = game:GetService("Players"):GetPlayerFromCharacter(Enemy)
if IsPlayer then
Remote:FireClient(IsPlayer,"CameraShake",{4,50,0,0.15})
end
end
end
if a:IsA("BasePart") and CollectionService:HasTag(a,"Destroyable") and not CollectionService:HasTag(a,"Regen") then
if not DestroyedPart[a] and not a:IsDescendantOf(DestroyedFolder) then
DestroyedPart[a] = {
["Part"] = a,
["Parent"] = a.Parent,
["Transparency"] = a.Transparency,
}
end
if a.Size.X >= 1 and a.Size.Y >= 1 and a.Size.Z >= 1 then
local Cloned = a:Clone()
Cloned.Parent = DestroyedFolder
Cloned.Size = Vector3.new(a.Size.X/1.1,a.Size.Y/1.1,a.Size.Z/1.1)
Cloned.CFrame = a.CFrame
Cloned.Anchored = false
Cloned.CanCollide = true
end
a:Destroy()
end
end
for i = 1,SlashPerRound do
Remote:FireAllClients("Slashes",{
["Parent"] = SlashesFolder,
["CFrame"] = Shrine:WaitForChild("Shrine2").CFrame * CFrame.new(rng(-VisualRange/2,VisualRange/2),0,rng(-VisualRange/2,VisualRange/2)) * CFrame.fromEulerAnglesXYZ(rng(-180,180),0,rng(-180,180)),
})
end
local Divined = 1
if Rock == 2 then
Divined = 1
elseif Rock == 1 then
Divined = 2
end
if Rock ~= 0 then
Remote:FireAllClients("RayCastRock",{
["User"] = Character,
["Type"] = "PebbleFly",
["Loop"] = rng(10,15)/Divined,
["Parent"] = RockFolder,
["DespawnTime"] = 1,
["DelayTime"] = 3,
["Part"] = Shrine:WaitForChild("Shrine2"),
["Force"] = rng(40,100),
["RayCast"] = {
["RayRange"] = -20,
["RayDistanceAway"] = VisualRange/2,
["RaySize"] = Vector3.new(rng(2,5),rng(2,5),rng(2,5)),
},
})
Remote:FireAllClients("RayCastRock",{
["User"] = Character,
["Type"] = "PebbleFly",
["Loop"] = rng(15,20)/Divined,
["Parent"] = RockFolder,
["DespawnTime"] = 1,
["DelayTime"] = 3,
["Part"] = Shrine:WaitForChild("Shrine2"),
["Force"] = rng(60,120),
["RayCast"] = {
["RayRange"] = -20,
["RayDistanceAway"] = VisualRange/2,
["RaySize"] = Vector3.new(1,1,1),
},
})
end
if Humanoid.Health <= 0 or Character.Parent == nil then
break
end
task.wait(0.05)
until tick() - Start >= Duration
CollectionService:RemoveTag(Character,"Attacking")
Debris:AddItem(FXFolder,16)
DestroyedFolder:Destroy()
task.delay(10,function()
for i, a in pairs(DestroyedPart) do
local Cloned = a.Part:Clone()
Cloned.Transparency = 1
Cloned.Parent = a.Parent
CollectionService:AddTag(Cloned,"Regen")
local Goal = {
Transparency = a.Transparency,
}
local Info = TweenInfo.new(1,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Cloned,Info,Goal)
Tween:Play()
Tween.Completed:Connect(function()
CollectionService:RemoveTag(Cloned,"Regen")
end)
end
end)
if Moveable == false then
Humanoid.WalkSpeed = SavedWalkSpeed
Humanoid.JumpPower = SavedJumpPower
Humanoid.JumpHeight = SavedJumpHeight
Action:Stop()
Root.Anchored = false
Humanoid.AutoRotate = true
end
Shrine:WaitForChild("Shrine2").Saw:Stop()
local Goal = {
Brightness = 0,
Contrast = 0,
TintColor = Color3.fromRGB(255, 255, 255)
}
local Info = TweenInfo.new(1,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Slashing,Info,Goal)
Tween:Play()
Tween.Completed:Connect(function()
Slashing:Destroy()
end)
Shrine.Highlight.FillColor = Color3.fromRGB(0, 0, 0)
local Goal = {
OutlineTransparency = 0,
FillTransparency = 0,
}
local Info = TweenInfo.new(2,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Shrine.Highlight,Info,Goal)
Tween:Play()
for _, part in pairs(Shrine:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
end
end
local Goal = {
Volume = 0
}
local Info = TweenInfo.new(1,Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Shrine:WaitForChild("Shrine2").OST,Info,Goal)
Tween:Play()
local Goal = {
CFrame = SavedCF * CFrame.new(0, -30, 12)
}
local Info = TweenInfo.new(2, Enum.EasingStyle.Sine)
local Tween = TweenService:Create(Shrine2, Info, Goal)
Tween:Play()
Tween.Completed:Connect(function()
task.wait(1)
Shrine:Destroy()
end)
task.delay(Cooldown, function()
CollectionService:RemoveTag(Character, "MalevolentShrineCD")
end)
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.