How to define OTHER players

You can write your topic however you want, but you need to answer these questions:

  1. I’m trying to make it when my tool hits another player, I am able to change THAT OTHER players properties.

  2. The issue is that I don’t really know how to achieve this, I’m not an advanced scripter.

  3. The furthest I’ve gotten is making a Remote Event and connecting it to the Tools script and a script in ServerScriptService.

My problem is that I am not really a scripter. I know basic stuff, and this seems advanced to me! But so far I have a RemoteEvent called when you click the tool, then I have it sent to a script in ServerScriptService. I’m not sure how to make it so that when the tool collides with another player, I am able to edit that other players properties, an example being: You swing the tool, it hits another player and it turns their torso red. If you could please help, that would be greatly appreciated, thanks!

1 Like

All you need is the part that is getting touched, from there we can extract the player’s character and all the other necessary stuff.

In this example I’ll be using .Touched.

local PS = game:GetService("Players")

local part: BasePart

part.Touched:Connect(function(touch)
	local char = touch:FindFirstAncestorWhichIsA("Model")
	local hum = char and char:FindFirstChildWhichIsA("Humanoid")
	
	if hum then
		-- do stuff here
	end
end)
1 Like

In this example, what does

local part: BasePart

Representing? Is that the part getting hit?

1 Like

Pretty much, yeah.

[dont mind this]

1 Like

So should I keep the Remote Event? Will I need that still, because the main script thats in the tool is a Local Script. (Sorry for all the questions, I’m more of a Builder and Animator then Scripter)

So I have been playing around with some of the code from your test to see if I can make it work, and I get this error

Workspace.EpicmanMarios33.NormalBonker.LocalScript:20: attempt to index nil with ‘Touched’ - Client - LocalScript:20

This error is just from your script pasted into my script. The script is a local script inside the tool, and it is under a .Activated script

1 Like

Remember to change the local part to the part where the tool hits someones. Like if it’s the sword then the blade part.

1 Like

I just saw this now, and I set it to:

local part = Tool.TopPart.Wood

That’s the main end part of my hammer, the part that you would usually hit someone with if you hit someone with a hammer lol. I am still getting the same error message though.

Yes because it doesn’t know what ‘Tool’ is? If the script is under the tool you can do script.Parent.TopPart.Wood for example.

1 Like

Sorry, I should have clarified, I already have Tool defined as

local Tool = script.Parent

Well then it must be wrong, since it says it is nil. That means it can’t find anything there.

Oh im so stupid, it was in the wrong place, I fixed it!