#Forsaken chase layers
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
wow
anyways
Serverscript:
local Runservice = game:GetService("RunService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local Character = script.Parent
local player = Players:GetPlayerFromCharacter(Character)
local Values = Character:FindFirstChild("Values")
local function OnCharacterAdded()
if not player then return end
local RootPart = Character:FindFirstChild("HumanoidRootPart")
if not RootPart then return end
if not Values then return end
local killer = Values:FindFirstChild("Killer")
if not killer then return end
local Connection
Connection = Runservice.Heartbeat:Connect(function()
SphereCast()
end)
-- Clean up connection when character dies/respawns
local humanoid = Character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
if Connection then
Connection:Disconnect()
end
end)
end
end
local function chase()
if Character then
OnCharacterAdded()
end
player.CharacterAdded:Connect(OnCharacterAdded)
end
-- Handle existing players
chase()
-- Handle new players
Players.PlayerAdded:Connect(chase)
local eventfolder = ReplicatedStorage.Events.Killer
local Events = {
["2011X"] = {
eventfolder["2011X"].ChaseTheme.PlayChase4;
eventfolder["2011X"].ChaseTheme.PlayChase3;
eventfolder["2011X"].ChaseTheme.PlayChase2;
eventfolder["2011X"].ChaseTheme.PlayChase1;
};
};
local chasetheme = SoundService["2011X"].sonichase
local Layer = {
layer1 = {
0, --Layer1 of the chase theme, TimePosition = 0:00
60, --Amount of studs to activate, 60 studs
0.5, --Volume
0.5, --Fadetime
},
layer2 = {
31.8, --Layer2 of the chase theme, TimePosition = 0:31.800
50, --Amount of studs to activate, 60 studs
0.5, --Volume
0.5, --Fadetime
},
layer3 = {
59, --Layer3 of the chase theme, TimePosition = 0:60.100
40, --Amount of studs to activate, 60 studs
0.5, --Volume
1, --Fadetime
},
layer4 = {
83, --Layer4 of the chase theme, TimePosition = 1:23
30, --Amount of studs to activate, 60 studs
1, --Volume
1.5, --Fadetime
},
}
local function SphereCast()
-- The initial position of the cast spherical shape
local originPosition = Vector3.new(Character.HumanoidRootPart.CFrame)
-- The radius of the cast spherical shape in studs
local radius = 10
-- The direction the sphere is cast in
local direction = Vector3.new(0, -0.1, 0)
local distance = 0
-- Cast the sphere and create a visualization of it
local raycastResult = workspace:Spherecast(originPosition, radius, direction)
if not raycastResult then return end
local othercharacter = raycastResult.Instance.Parent
if not othercharacter then return end
local otherplayer = Players:GetPlayerFromCharacter(othercharacter)
if not otherplayer then return end
if raycastResult then
local distance = raycastResult.Distance
print("Hit distance: ", distance)
print("Sphere intersected with: ".. othercharacter)
if distance < Layer.layer1[2] then
Events["2011X"][1]:FireClient(player)
Events["2011X"][1]:FireClient(otherplayer)
end
end
end
Here is the local script:
I hope you dont mind it being a bit long.
youre gonna have to elaborate on what a chase theme is