So I got 2 scripts the first is a local script and the other one a server script
First One:
local tool = script.Parent
local Player = game.Players.LocalPlayer -- Getting the player
local char = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse() -- Getting the players mouse]
local RS = game:GetService("ReplicatedStorage")
local MakimaEvent = RS.Events:WaitForChild("Makima")
Mouse.Button1Down:Connect(function() -- Detecting when the player presses the left mouse button
if tool.Parent == char then
local clickchar = Mouse.Target.Parent
if clickchar:FindFirstChild("Humanoid") then -- Checking if the Mouse is over a player
local dist = (char.HumanoidRootPart.Position - clickchar.HumanoidRootPart.Position).Magnitude
if dist <= 30 then
print(Mouse.Target.Parent.Name)
local enemy = Mouse.Target.Parent
MakimaEvent:FireServer(enemy)
end
end
end
end)
Second One:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RS = game:GetService("ReplicatedStorage")
local MakimaEvent = RS.Events:WaitForChild("Makima")
local VFX = RS:WaitForChild("VFX")
local Blood = VFX:WaitForChild("Blood")
local function onMakimaFired(enemy)
local NewBlood = Blood:Clone()
NewBlood.Parent = workspace
NewBlood.Position = enemy:WaitForChild("Torso")
end
MakimaEvent.OnServerEvent:Connect(onMakimaFired)
So I am trying to pass the enemy to the server but this doesnt really work because it gives me the player and not the person who I clicked on for some reason.
Can someone help me?