How to get the char from :GetPlayerFromCharacter?

the script gets the name of anything it clicks, not the parent (which I need the player, and the char)

I know it can, I just name it those cuz organization

If it’s underlined in Yellow, then it’s just a type error and won’t affect the script. If it’s underlined in Red then there’s an error somewhere

Then how are you using :GetPlayerFromCharacter() ?

I don’t know, the person who sent it to me didnt explain everything through. I should have rewritten it but I am super confused on getting the mouse’s position that i just need something that works

its orange. I think it affects something

FindFirstAncestorWhichIsA(“Model”) will tell you if the hit part is part of a model. If the model contains a humanoid and Players:GetPlayerFromCharacter(OtherModel) returns a player, it is a player character

		-- Finds if the touched part is part of a model
		--       For parts that are not part of a model, this will return as Workspace
		local OtherModel = OtherPart:FindFirstAncestorWhichIsA("Model")
		-- If the touched model exists and contains a humanoid (living creature)
		if OtherModel and OtherModel ~= game.Workspace and OtherModel:FindFirstChildWhichIsA("Humanoid") then
			-- If the hit model is a player character
			local Victim = Players:GetPlayerFromCharacter(OtherModel)
			if Victim then
				-- A player character has been hit
			end
		end

You raycasted the mouse’s position to get the target, right? I don’t understand why you can only get the name of the thing you’ve hit-

I am trying to damage the player but i need the character first, which i used hitcast to get the player, and i didnt know how, i asked a server but they werent any help they just gave me gibberish and I dont even know where i started

Well, maybe just try going into much more depth?

Ill try to find a tutorial on it instead. hopefully they have something useful.

Sorry if my posts aren’t ‘useful’ so far, I am just struggling to understand what you’re doing. You just gave us the server part, but we don’t know what you’re doing on the client…

yes sorry, i should have just searched it up anyway. I am still getting into depth of the advanced code.

Ofc its gonna be focasds, he’s been there for years helping so he must got mad at simple stuff after repeating.

:GetPlayersFromCharacter() gets the player from a character.
Target.Parent is the character.

Also, I wrote the script the same as you, and did not get any warning.

So can you HOVER over the warning line and us what it says? When u hover on the line, its supposed to tell you the warning.

1 Like

Don’t apologize. Maybe just read some more documentation on what you’re having the problem with? That always helps me.

1 Like

I didn’t get a warning either lol, also I didn’t know you were in the server anyway.

Anyways, I understand it gets the player from a character, but how do i get the char then? I know its a stupid question but I seriously dont know how i can getplayerfromcharacter and get the character after doing the complete opposite.

If you did :GetPlayerFromCharacter(Target.Parent), then Target.Parent is the character. You can’t get the character if you already have it.

its been like 2 years since i left that server, but this man focasd is still here helping people

1 Like

Jeez, didnt know.

Also I tried to do target.parent, but it still printed the part it would touch, not the parent. adding to that, it lined orange so it never worked.

lined orange means its a WARNING. as i said, hover over that line and tell us what it says

2 Likes

Sending objects over a remoteevent can cause them to become nil or have a nil parent on the server.

1 Like