Projectile Tools Using the Evercyan Rpg Kit

I’m a rather new developer and have been working on an Undertale RPG game utilizing the Evercyan RPG kit. I noticed that the kit only supported melee weapons but It would be ideal if I could create ranged weapons using the kit. So I wondered if there would be a way to alter the damage scripts to achieve this. (I have already created the basic foundation of the tool but it’s currently unable to damage the enemies.)

Video of how the script functions (does no damage): https://gyazo.com/4714f0ffe219d6966a2c676ac030ea1f

Script Inside of Tool:

repeat wait() until script.Parent:FindFirstChild("WeaponConfig") ~= nil
local _M = require(script.Parent.WeaponConfig)
local debounce = false
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
valueCooldown = false

local SlashSound = Instance.new("Sound") 
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav" 
SlashSound.Parent = Handle 
SlashSound.Volume = .5
SlashSound.MaxDistance = 50

function SwordCore(hit)
   if script.CanDamage.Value and hit.Parent:FindFirstChild(_M.HumanoidToKill) then
   	local enemy = hit.Parent:FindFirstChild(_M.HumanoidToKill)
   	local chr = Tool.Parent 
   	local plr = game.Players:GetPlayerFromCharacter(chr)
   	if (not plr) then return end
   	local hum = chr:FindFirstChild("Humanoid")
   	if (not hum) then return end
   	if enemy ~= hum and (not debounce) then
   		if (enemy.Health < 1) then return end
   		if chr:FindFirstChild("Right Arm") then
   			debounce = true
   			local box = script.parent:WaitForChild("HitBox"):Clone()
   			local right_arm = chr:FindFirstChild("Right Arm")
   			local j = right_arm:FindFirstChild("RightGrip")
   			if (j and (j.Part0 == Handle or j.Part1 == Handle)) then
   				if (not enemy) then return end
   				game.ReplicatedStorage.GameRemotes.DamageEvent:FireServer(hit,enemy,Tool)
   			end
   		wait(_M.Cooldown)
   		debounce = false
   		end
   	end
   end
end


function onActivated()
   if (not Tool.Enabled) then return end
   Tool.Enabled = false
   local chr = Tool.Parent 
   local hum = chr:FindFirstChild("Humanoid") 
   local anim = hum:LoadAnimation(script.Parent.Slash) 
   if (hum == nil) then return end
   SlashSound:Play() 
   anim:Play()
   local box = script.parent:WaitForChild("HitBox"):Clone()
   local character = game.Players.LocalPlayer.Character
   local Torso = character.Torso
   box.CFrame = Torso.CFrame * CFrame.new(0,0.5,-1.3)
   box.Parent = Tool
   local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Humrp = character:FindFirstChild("HumanoidRootPart")
local speed = 150
   local Vel = Instance.new("BodyVelocity",box)
   Vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
   Vel.Velocity = Humrp.CFrame.lookVector * speed --direction.lookVector * speed 
   Debris:AddItem(box,2)



   script.Parent.Unequipped:Connect(function()
   	anim:Stop()
   end)
   wait(_M.Cooldown) 
   Tool.Enabled = true
end 


function onEquipped()
   if (not Tool) then return end
   if (not Handle) then return end
   if Handle.UnsheathSound.IsPlaying == false then
   	Handle.UnsheathSound:Play()
   end
end

function onUnequipped()
   if (not Tool) then return end
   if (not Handle) then return end
   Handle.UnsheathSound:Stop()
end

function checkValue()
   if valueCooldown == false then
   	valueCooldown = true
   	script.CanDamage.Value = true
   	wait(_M.Cooldown)
   	wait()
   	script.CanDamage.Value = false
   	valueCooldown = false
   end
end
local character = game.Players.LocalPlayer.Character
local box = script.parent:WaitForChild("HitBox"):Clone()
script.Parent.Activated:Connect(onActivated)
script.Parent.Activated:Connect(checkValue)
script.Parent.Equipped:Connect(onEquipped)
script.Parent.Unequipped:Connect(onUnequipped)
connection = box.Touched:Connect(SwordCore)
local box2 = game.ReplicatedStorage:FindFirstChild("HitBox"):Clone()
box2.Parent = script.Parent

2 Likes