What do you want to achieve? I was just working on an upcoming katana fighting game for my friend, and I am trying to handle the katana itself, using a clientsided script to fire remote events for a serversided script to handle.
What is the issue? I don’t know, that’s the issue,
Errors like these have been repeatedly happening without telling me what script is causing them, only referencing the client.
I know this is a script related issue however.
This is the explorer for all parts that could possibly be causing the errors.
I’m handing katana related events on the clientside first and then using remote events to handle them on the serverside.
Clientside script (inside katana tool)
local tool = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local charEvents = char:WaitForChild("CharEvents")
function equipped()
charEvents:WaitForChild("KatanaEquip"):FireServer(tool)
print("KatanaEquip")
end
function activated()
charEvents:WaitForChild("KatanaAttack"):FireServer()
print("KatanaAttack")
end
function unequipped()
charEvents:WaitForChild("KatanaUnequip"):FireServer()
print("KatanaUnequip")
end
tool.Equipped:Connect(equipped())
tool.Activated:Connect(activated())
tool.Unequipped:Connect(unequipped())
The error, I believe was partially caused (or entirely) by the client, but I am not sure if that is true or how.
ServersideHandler script (child of StarterPlayer.StarterCharacterScripts.CharEvents)
local events = script.Parent
function changeIdleAnim(char, id) -- Easily change idle animation
local animateIdle = char:WaitForChild("Animate").idle
animateIdle.Animation1.AnimationId, animateIdle.Animation2.AnimationId = id, id
end
function equip(plr, tool)
local char = plr.CharacterAdded:Wait()
local animator = char:WaitForChild("Humanoid").Animator
local animations = char:WaitForChild("Animations")
local equipAnim = animator:LoadAnimation(animations.KatanaEquip)
equipAnim:Play() -- Play equip animation
changeIdleAnim(char, "rbxassetid://14075694452")
local sound = tool.Handle.Sound -- Play sound
sound:Play()
-- Equip is always first to fire, so we can handle other events here as well
local function activate()
local fighting = require(game.ServerScriptService.FightingV3)
-- Different attacks based on pendingmove (not yet implemented)
local pendingMove = tool.PendingMove.Value
local HRP = char:WaitForChild("HumanoidRootPart")
if pendingMove == 1 then
local slash = animator:LoadAnimation(animations.KatanaSlash) -- Play slash animation
slash:Play()
local vectors = {}
vectors.Offset = CFrame.new(0, 0, -2)
vectors.Size = Vector3.new(2, 2, 2)
fighting.CreateAttack(HRP, vectors, 5, 0.25, true)
end
end
end
events.KatanaEquip.OnServerEvent:Connect(function(player, katana)
equip(player, katana)
end)
What solutions have you tried so far? Honestly, none other than attempts to dissect my code and figure out what went wrong.
Any help would be appreciated. If you would like to know more, just tell me.
This is my first post, so my apologies if I did something wrong.