Sending 2 variables with 1 event

Hi devs i looking for a way to send 2 variables through 1 event this is my script\s currently

--local
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character
local thun = game:GetService("ReplicatedStorage").Thunder
local Tool = char:WaitForChild("dash")
local mouse = plr:GetMouse()
local Camera = game.Workspace.CurrentCamera

mouse.Button1Down:Connect(function()
	if Tool then
		angle = Camera.CFrame.LookVector.Unit * 100
		print(angle)
		print("hello")
		thun:FireServer(plr, angle)
		print("fire")
	end
end)

/

    --Server
local thun = game:GetService("ReplicatedStorage").Thunder

thun.OnServerEvent:Connect(function(plr, angle)
	local char = plr.Character
	print(angle)
	local ray = Ray.new(char.Position, angle)
	
	local hit, position = game.Workspace.FindPartOnRayWithIgnoreList(ray, {char})
	if hit then
		print("oof")
		local Rham = hit.Parent:FindFirstChild("Humanoid")
		if Rham then
			Rham.Health -= 50
			print("hit!")
		end
	end
end)

Modify this.

    --Server
local thun = game:GetService("ReplicatedStorage").Thunder

thun.OnServerEvent:Connect(function(plr, angle, secondvar)
	local char = plr.Character
	print(angle)
	local ray = Ray.new(char.Position, angle)
	
	local hit, position = game.Workspace.FindPartOnRayWithIgnoreList(ray, {char})
	if hit then
		print("oof")
		local Rham = hit.Parent:FindFirstChild("Humanoid")
		if Rham then
			Rham.Health -= 50
			print("hit!")
		end
	end
end)

Just simply put another variable and make the client fire it like this.

thun:FireServer(angle, secondvar)

You don’t fire in the local player in FireServer, it does so automatically, pass in any other arguments besides it

2 Likes

As @EmbatTheHybrid said, you wouldn’t include plr in the fireserver, then the angle would be a plaeyr and the secondvar would be the angle

My bad, forgot to remove the plr variable.