Things happening only to player 1

so i have a part that when you touch it ragdolls the player
the issue is it works for player 1 just fine but when player 2 touches the part player 1 ragdolls instead of player 2

player 1 perspective
robloxapp-20240228-1600445.wmv (1.4 MB)

player 2 perspective
robloxapp-20240228-1600561.wmv (1.9 MB)

here is the script placed in the part

-- local part = script.Parent
local RE = game.ReplicatedStorage.RemoteEvent

local players = game:GetService("Players")
local player = players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")



function fall(otherPart)
	character = otherPart.Parent
	if character:FindFirstChildOfClass("Humanoid") then
		RE:FireClient(player, part)

	end
end

part.Touched:Connect(fall)

and here is the connected function in starterCharacterScripts

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(player, part)
	Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
	wait(3)
	Humanoid:ChangeState(Enum.HumanoidStateType.PlatformStanding)
end)

any help is appreciated

I’m presuming this is not a local script since your using FireClient in it so…
these lines can be removed as there’s no point to them

local player = players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")

and to fire the client of the person who touched the part use

RE:FireClient(players:GetPlayerFromCharacter(character), part)

In your second script (local script) OnClientEvent doesn’t capture the player so change it to

.OnClientEvent:Connect(function(part)

this gets rid of my variables for the otherPart.Parent

just make the character variable local to that function.

function fall(otherPart)
	local character = otherPart.Parent
	if character:FindFirstChildOfClass("Humanoid") then
		RE:FireClient(players:GetPlayerFromCharacter(character), part)

	end
end

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