I am making a skill test script on my game which works by sending a server event request to a script in order to activate the skill, but I am having a very weird problem.
I tried to fix this several times but nothing worked, the problem is that when the serverside script is activated, it's supposed to print the name of the person that has casted the skill and then print the name of the target. But instead it prints the name of the caster twice, this problem doesn't happen on the local script and I have no idea why.
Local script:
--//Services
local players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
--//Variables
local remotes = repStorage:WaitForChild("Remotes")
local player = players.LocalPlayer
local mouse = player:GetMouse()
--//Skills
local soulReapRemote = remotes:WaitForChild("CastSkill_SoulReap")
--//Functions
local function onKeyPress(input, isTyping)
if isTyping then return end
if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
local mouseTarget = mouse.Target
if input.KeyCode == Enum.KeyCode.G then
if mouseTarget.Parent:FindFirstChild("Humanoid") then
local caster = workspace:FindFirstChild(player.Name)
local target = workspace:FindFirstChild(mouseTarget.Parent.Name)
print("Caster: ".. caster.Name..", Target: ".. target.Name..".")
soulReapRemote:FireServer(caster, target)
end
end
end
--//Callers
UIS.InputBegan:Connect(onKeyPress)
Serverside script:
--//Services
local repStorage = game:GetService("ReplicatedStorage")
--//Variables
local remotes = repStorage:WaitForChild("Remotes")
--//Skills
local soulReapRemote = remotes:WaitForChild("CastSkill_SoulReap")
--//Functions
local function onSoulReapCast(wCaster, wTarget)
print("Caster: ".. wCaster.Name..", Target: ".. wTarget.Name..".")
end
--//Callers
soulReapRemote.OnServerEvent:Connect(onSoulReapCast)
I'm sorry if this wasn't very understandable, I don't know how to describe it better, hope you understand!

1 comment
It worked, thanks