What I’m trying to achieve here is the usage of spells through module scripts. What my problem is I don’t know how to make it so if you say the spell “Incendia” it does what’s in the module script (Second Code) I’ve just started to learn about module scripts so I'm stuck on this. If you need more clarification I will provide
local Code = {}
local Players = game.Players
local ReplicatedStorage = game.ReplicatedStorage
local Modules = ReplicatedStorage.RModules
local TweenModule = require(Modules.Tweening)
local Assets = ReplicatedStorage.ReplicatedAssets
local WitchFolder = Assets.WitchesAssets
local AnimationsFolder = Assets.Animations
local EffectsFolder = Assets.Effects
local SoundsFolder = Assets.Sounds
local RemoteEvents = ReplicatedStorage.RemoteEvents
local PlayAnimationEvent = RemoteEvents.AnimationClientEvent
local t = 1
function Code.Execute(Character,ContentTable)
local Player = Players:GetPlayerFromCharacter(Character)
local Target = ContentTable.Target
local TargetPlayer = ContentTable.TargetPlayer
local Damage
Damage = 2
local fire = ReplicatedStorage.FireParticle.Fire:Clone()
fire.Parent = Target.UpperTorso
local result = 15 * t
for t = 1,result,1 do
Target.Humanoid.Health -= Damage
wait(0.2)
end
fire:Destroy()
end
return Code
Here's the second code:
local ReplicatedStorage = game.ReplicatedStorage
local Storage = ReplicatedStorage.SpellsModules
local Spells = {
["Incendia"] =
{
Launch = Storage.Incendia,
Input = Enum.UserInputType.MouseButton1,
Cooldown = 8,
Spell= "Incendia",
Magnitude = 30,
Magic = 60,
},
}
return Spells
To find the spells name when you say it in chat:
local ClickEvent
local WitchSpellEvent = RemoteEventFolder.WitchSpell
local function WitchTyped(msg)
local SpellsModule = require(ReplicatedStorage.r.SpellsConfiguration)
local FilteredMessage = msg:lower():gsub("\r","")
print("Client said ''"..msg.."''")
local function IdentifyTarget()
local Target = Mouse.Target
if Target.Parent == nil then return end
if Target.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
return Target.Parent
elseif Target.Parent:IsA("Accessory") and Target.Parent.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
return Target.Parent.Parent
end
end
for SpellName,Table in pairs(SpellsModule) do
local incantation = Table.Key:lower()
local inputType = Table.Input
if FilteredMessage == incantation then
if inputType == Enum.UserInputType.TextInput then
WitchSpellEvent:FireServer({IncantationText = incantation})
elseif inputType == Enum.UserInputType.MouseButton2 then
if ClickEvent ~= nil then
ClickEvent:Disconnect()
print("disconnected last event spell!")
end
ClickEvent = UserInputService.InputBegan:Connect(function(Input,Processed)
if Processed then return end
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
local target = IdentifyTarget()
print("Clicked!")
if target ~= nil then
WitchSpellEvent:FireServer({IncantationText = incantation,Target = target})
ClickEvent:Disconnect()
print("sent signal!")
end
end
end)
end
elseif string.find(FilteredMessage,incantation) ~= nil and Table.Input == Enum.UserInputType.InputMethod then
if string.split(FilteredMessage,incantation.." ") ~= "" then
--print(incantation)
--print(string.split(msg:gsub("\r",""),incantation.." ")[2])
local char = string.split(msg:gsub("\r",""),incantation.." ")[2]
WitchSpellEvent:FireServer({IncantationText = incantation,TextTarget = char})
end
end
end
end
Player.Chatted:Connect(WitchTyped)

1 comment
I seem to be a little confused because im trying to get this to work but it's not working