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!
im attempting to make a function in a module that handles all of my killstreak phase stuff -
What is the issue? Include screenshots / videos if possible!
everytime i call the function, anything after a task.wait() NEVER gets called -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
ive tried switching it to just wait(), and calling the function without task.spawn()
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!
the module so far:
(Located in ServerScriptService)
local module = {
GlobalTasks = {}
}
module.KillsUpdate = function(plr)
local char = plr.Character
local HRP = char.HumanoidRootPart
local hum = char.Humanoid
local function FindTool()
if char:FindFirstChildOfClass("Tool") then
return char:FindFirstChildOfClass("Tool")
elseif plr.Backpack:FindFirstChildOfClass("Tool") then
return plr.Backpack:FindFirstChildOfClass("Tool")
end
end
local tool = FindTool()
if tool == nil then
warn("No Tool!")
end
local kills = tool.Kills.Value
local Overhead = char.Head.Overhead
Overhead.Label.Text = kills
local phases = game.ReplicatedStorage.KillstreakPhases
local phase1 = phases:WaitForChild("Phase1")--5
local phase2 = phases:WaitForChild("Phase2")--10
local phase3 = phases:WaitForChild("Phase3")--25
local phase4 = phases:WaitForChild("Phase4")--50
local phase5 = phases:WaitForChild("Phase5")--75
local phase6 = phases:WaitForChild("Phase6")--100
local phase7 = phases:WaitForChild("Phase7") --250
local phase8 = phases:WaitForChild("Phase8") --500
local phase9 = phases:WaitForChild("Phase9") --777 1255
local phase10 = phases:WaitForChild("Phase10") --1000
local EquipMod = require(script.BasicEquip)
local arr = {
[5] = function()
print("5 kills")
local function effects()
local moosic = script.KsMusic:Clone()
moosic.Parent = HRP
moosic:Play()
print("began")
task.wait(19.5)
print("waited")
EquipMod.Basic(phase1,char)
end
local core = task.spawn(effects)
module.GlobalTasks[plr.Name] = core
end,
[10] = function() print("10 kills")
if module.GlobalTasks[plr.Name] then task.cancel(module.GlobalTasks[plr.Name]) print("cancel") end
EquipMod.Unbasic(char)
--other 10 kills stuff
end,
[25] = function() print("25 kills")
end,
}
local fn = arr[kills]
if fn then fn() end;
end
return module
why does it just not use the task.wait()'s?
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.