I have a sword tool which runs on a LocalScript. Basically I want it to send the server what it touched and the damage.
For some reason my server-side script that's handling all of that is mixing up those parameters the cilent sends. I tried switching the parameters/arguments around and it didn't work.
I also cannot convert the LocalScript to a regular script since my sword uses UserInputService to do special attacks and moves. If I switch scripts errors would pop up and my sword can't use those special key-binded moves.
If you like I'll provide my LocalScript and my Server-Side Script with the snippets:
LocalScript:
if game.Players:GetPlayerFromCharacter(Hit.Parent).Team == "Zombies" then RemoteEvent:FireServer(Hit, 125) --125 is the damage end --these blocks are inside an Touched Event so we have the hit parameter.
Server-Side Script:
local RemoteEvent = game.ReplicatedStorage.Remotes.MeleeRemoteEvent local function ServerEventl(Hit, Damage) local Humanoid = Hit.Parent.Humanoid Humanoid:TakeDamage(Damage) end RemoteEvent.OnServerEvent:Connect(ServerCall)
The errors the server-side script usually are just making hit as an float number and damage as the object, I switched those around and it threw the same error at me.
Thank you for Reading
Hey, when a server script receives an event from the client, the first parameter will always be the player, followed by the rest of the arguments sent. keep this in mind.
local RemoteEvent = game.ReplicatedStorage.Remotes.MeleeRemoteEvent local function ServerEventl(player, Hit, Damage) -- the player that fired the remote is the first parameter. local Humanoid = Hit.Parent.Humanoid Humanoid:TakeDamage(Damage) end RemoteEvent.OnServerEvent:Connect(ServerCall)