Help with parameters

I need help with my parameters, i recently discovered you can’t get a module script from a local script so i decided to pass the parameters to a server so it can fire from there, however somewhere along the way the parameters move up one time, please help.

local script

UIS.InputBegan:Connect(function(input, gpe)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			if plr:FindFirstChild("eStun") == true then return end
			if db then return end
			if not equipped then return end
			db = true
			if tick() - ctime > 2 then
				cpunch = 0
			end
			
			if cpunch == 0 then
				hum.WalkSpeed = 5
				hum.JumpPower = 0
				h1:Play()
				HBE:FireServer(char, hum, hrp, 1.5,.5, 2)
				h1.Ended:Connect(function()
					hum.WalkSpeed = 16
					hum.JumpPower = 50
					cpunch = 1
					db = false
				end)

–server script

local hitevent = game.ReplicatedStorage.PlayerEvents.HitBoxEvent
local Hitbox = require(game.ServerScriptService["M1's"].HITBOX)

hitevent.OnServerEvent:Connect(function(char, hum, hrp, dmg,deletetime,punchnum)
	Hitbox.M1(char,hum,hrp,dmg,deletetime,punchnum)
end)

–hitbox module

local module = {}
function module.M1(char,hum,hrp,dmg,deletetime,punchnum)
	local weld = Instance.new("Weld")
	local HB = Instance.new("Part")
	local debris = game:GetService("Debris")
	local rs = game.ReplicatedStorage
	local hitanims = rs.Animations.hitAnimations
	local Kb = require(game.ServerScriptService["M1's"].Knockback)
	weld.Parent = char
	HB.Parent = char
	HB.Massless = true
	HB.CastShadow = false
	HB.Transparency = 0
	HB.Massless = true
	HB.CanQuery = false
	HB.CanCollide = false
	HB.Size = Vector3.new(3,3,3)
	HB.CFrame = hrp.CFrame + hrp.CFrame.LookVector * Vector3.new(2).X + Vector3.new(0,0)
	
	weld.C0 = HB.CFrame:Inverse()
	weld.C1 = hrp.CFrame:Inverse()
	
	weld.Part0 = HB
	weld.Part1 = hrp
	
	debris:AddItem(HB, deletetime)
	debris:AddItem(weld, deletetime)
	
1 Like

hitevent.OnServerEvent:Connect(function(PLAYER, char, hum, hrp, dmg,deletetime,punchnum)

When you listen the remote on server, the first parameter is the Player instance, then the rest of params you sent

so on the local script do i define the player or what

Nope, the player is received automatically without the need of define it

so how do i fix my problem? do i change the vairables?

Just use the line I typed instead of the line you are using, include the Player param into your OnServerEvent()

Use this
hitevent.OnServerEvent:Connect(function(PLAYER, char, hum, hrp, dmg,deletetime,punchnum)

instead of this:
hitevent.OnServerEvent:Connect(function(char, hum, hrp, dmg,deletetime,punchnum)

Actually an improvement of the code could be, not even sending the Char, Hum, Hrp, you can get all of those from the Server script using the Player instance got from the remote and OnServerEvent (only if we are speaking of the same player that activated the remote, if you are trying to target a different player, no)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.