You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Make this module clone a snowball and throw it.
-
What is the issue? For some reason, it works the first time, then it will not “throw” unless i click it twice fast (Which I cannot due to a debounce feature I added)
Script in ServerScriptService
local Subject
local SnowBallModule = require(game:GetService("ServerScriptService").Modules.Snowball)
function SnowballFunction()
local Snowball = Subject
SnowBallModule.Snowball(Snowball)
end
for i,v in pairs(workspace:GetDescendants()) do
if v:IsA("Tool") and v.Name == "Snowball" then
Subject = v
Subject.Activated:Connect(SnowballFunction)
end
end
Module
local module = {}
local SModule = require(game:GetService("ServerScriptService").Modules.SoundPlayer)
local Connection
local Cooling = false
function module.Snowball(Item)
if Cooling == true then return end
Cooling = true
--[Animating]--
local Character = Item.Parent
local Animation = Character:FindFirstChild("Humanoid"):LoadAnimation(game:GetService("ServerStorage").Animations.SnowballAnimation)
Animation.Priority = Enum.AnimationPriority.Action2
Animation:Play()
--[Sound]--
SModule.SoundPlay(game:GetService("ServerStorage").Sounds.Woosh,Character.PrimaryPart)
--[Cloning]--
local Clone = Item.Snowball:Clone()
Clone.Parent = workspace
Clone.Trail.Enabled = true
Clone.BreakableWeld:Destroy()
Clone.CanCollide = true
Clone:ApplyImpulse(Item.Parent.PrimaryPart.CFrame.LookVector * 10)
print("pushed")
--[Destroy]--
--[Cooldown]--
task.wait(game:GetService("ServerStorage").Settings.SnowballCooldown.Value)
Cooling = false
end
return module