Passing variables through remotes

So I’m trying to work on a system that spawns a hitbox on the client, then fires a remote to the server where damage is calculated. I’ve got a picture below of the main function I’m using to spawn the hitboxes.

Now I’ve honestly got no idea if I’m going about it the right way and some of the code isn’t even fully fleshed out yet because I just wanna get the remote aspect working first, but getting the targets humanoid on the server does work properly, and the code does fire to the server.

image
image

Only problem is when it fires to the server, server has no idea what targetHmd is, and so I have no idea how to calculate damage on the server when I can’t even get the humanoid to pass through to the server.

Anyway if anybody knows what I’m missing or if I’m doing something dumb I would appreciate the help.

1 Like

Hey there! I think I know your problem, it’s in your server script.
Try using print(targetHmd.Parent.Name)


Sadly doesn’t work, still indexes nil.

Are you sure targetHmd is on the server and not just on the client?

It should be just on the client right now. I have the hitbox created on the client to find targetHmd, then I have the remote tell the server what targetHmd is. Though the server doesn’t understand that.

I started messing with the code a bit more and realized I can pass a table through just fine though.

My idea was to get the targets humanoid on the client and then sanity check it on the server. Would it be better just to do all of that on the server?

If the humanoid only exists on the client, then it wont replicate to the server. Make sure the Humanoid exists on the server too.

Forgive me if I didn’t understand your post, I’m literally using my phone whilst on a boat in Paris, when I am on PC I can understamd and articulate stuff better.

I might also be misunderstanding, but the humanoid that’s found should already exist on the server since it’s in a workspace model (i am using the default roblox zombie guy for testing say hi)

image

targetHmd is created on the client, and is just used to hold information. This way I can make sure targetHmd is a humanoid that should be damaged (doing this to avoid damaging the player who creates the hitbox). If the client gets Drooling Zombie’s Humanoid, then Drooling Zombie’s Humanoid should equal targetHmd. Then the targetHmd variable should be sent to the server for damage testing.

I might be misunderstanding your point so sorry if this is a big nothing post, but I appreciate the help from everyone.

There must be something wrong when defining the targetHmd in the localScript

Ended up fixing it by inserting targetHmd instead of targetHmnd.Name

	load:GetMarkerReachedSignal("activeFrames"):Connect(function(paramString)
		print("activeFrames")
		hitbox.BrickColor = BrickColor.new(0,255,0)
		hitbox.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid") ~= humanoid then
				local targetHmd = hit.Parent:FindFirstChild("Humanoid")
				if not table.find(hitTargets, targetHmd) then 
					table.insert(hitTargets, targetHmd) -- change here
					print(hitTargets)
					combatRemote:InvokeServer(targetHmd, hitTargets, hitbox, debounce)
				end
			end
	end)
end)

Thank you for the help everyone.

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