local Player = game:GetService("Players").LocalPlayer
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
local mouse = Player:GetMouse()
ArrestEvent:FireServer(mouse.Target)
end
end)
end)
server script:
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
ArrestEvent.OnServerEvent:Connect(function(player, mouse.Target)
print(mouse.Target)
end)
Remember that parameters are local variables, so you need to use a valid identifier. mouse.Target is not a valid identifier because it contains a period, but target for example is a valid identifier.
What @sjr04 is trying to say is that you’re assigning the name “mouse.Target” to a parameter, which is an invalid name. You cannot have periods in variable names, among other things.
The simple fix is to change mouse.Target to mouse when you declare your parameters:
ArrestEvent.OnServerEvent:Connect(function(player, mouse) -- changed mouse.Target to mouse
print(mouse.Target)
end)
On localscript you should use mouse.Hit.p instead of mouse.Target
local Player = game:GetService("Players").LocalPlayer
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
local mouse = Player:GetMouse()
ArrestEvent:FireServer(mouse.Hit.p)
end
end)
end)
On Server it should receive the signal of mouse.Hit.p
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
ArrestEvent.OnServerEvent:Connect(function(player, mousePosition)
print(mousePosition)
end)
local Player = game:GetService("Players").LocalPlayer
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
local mouse = Player:GetMouse()
ArrestEvent:FireServer(mouse.Target)
end
end)
end)
server script:
local RepStorage = game:GetService("ReplicatedStorage")
local ArrestEvent = RepStorage:FindFirstChild("Arrest")
ArrestEvent.OnServerEvent:Connect(function(player, mouseTarget)
print(mouseTarget)
end)