OnServerEvent is not a valid member of Part

Hello developers, today I was making a seed system like this (It is activated when you press a key):

But unfortunately everything had been done to the client and only I could see it, that’s why I created a remote event with a fire server. I created a server script and i put this code:
Server Script (Server) No full Code :

local effectRed =  Instance.new("Part")
effectRed.Shape = Enum.PartType.Cylinder
effectRed.Material = Enum.Material.Neon
effectRed.Size = Vector3.new(0.37, 1.164, 32.288)
effectRed.CanCollide = false
effectRed.Anchored = true


effectRed.OnServerEvent:Connect(function(plr)
	effectRed.Parent = plr.HumanoidRootPart
	effectRed.Position = plr.HumanoidRootPart.Position

	local info = TweenInfo.new(
		0.3,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local goals = 
		{
			Size = Vector3.new(0.37, 28.147, 32.288)
		}

	local makepart = TweenService:Create(effectRed,info,goals)
	wait(0.01)
	makepart:Play()



	local info2 = TweenInfo.new(
		0.3,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local goals3 = 
		{
			Size = Vector3.new(0.37, 1.164, 32.288)
		}

	local makepartFinal = TweenService:Create(effectRed,info2,goals3)
	wait(0.3)
	makepartFinal:Play()
	wait(0.1)
	effectRed:Remove()
end)

And I get this error, I don’t understand it, I looked everywhere and I don’t understand the reason
image

Local Script (Client) : No full code

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Z and redbean.Value >= 1 then
		redbean.Value -= 1
		
       redevent:FireServer()
		
		
		indicator:TweenPosition(UDim2.new(0.035, 0,0.819, 0),

			Enum.EasingDirection.In,
			Enum.EasingStyle.Linear,
			0.25

			,true)

		script.Sound:Play()
		wait(5)
		indicator:TweenPosition(UDim2.new(-0.9, 0,-0.93, 0),

			Enum.EasingDirection.In,
			Enum.EasingStyle.Linear,
			0.25

			,true)

		
		
	print("Se esta usando la Red Bean! Espera 6 segundos para volverla a usar")
	task.wait(6)
	print("Ya puedes usar la Red Bean Bro!")

	remotes.Senzu:FireServer()
end
1 Like

Change to remotes.Senzu.OnServerEvent… (you didnt said whats “remotes”, so change remotes do the Remote Folder)

The part instance does not have an event called OnServerEvent. I think you want to use a RemoteEvent | Roblox Creator Documentation

ty but
image
I think it works now but it doesn’t capture the character
you know how to fix it?
It is only capturing the Player, but not the character

HumanoidRootPart is located on the character, not the player instance.

local effectRed =  Instance.new("Part")
effectRed.Shape = Enum.PartType.Cylinder
effectRed.Material = Enum.Material.Neon
effectRed.Size = Vector3.new(0.37, 1.164, 32.288)
effectRed.CanCollide = false
effectRed.Anchored = true

local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game.ReplicatedStorage


RemoteEvent.OnServerEvent:Connect(function(plr)
	effectRed.Parent = plr.Character.HumanoidRootPart
	effectRed.Position = plr.Character.HumanoidRootPart.Position

	local info = TweenInfo.new(
		0.3,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local goals = 
		{
			Size = Vector3.new(0.37, 28.147, 32.288)
		}

	local makepart = TweenService:Create(effectRed,info,goals)
	wait(0.01)
	makepart:Play()



	local info2 = TweenInfo.new(
		0.3,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local goals3 = 
		{
			Size = Vector3.new(0.37, 1.164, 32.288)
		}

	local makepartFinal = TweenService:Create(effectRed,info2,goals3)
	wait(0.3)
	makepartFinal:Play()
	wait(0.1)
	effectRed:Remove()
end)

i think you can do it with

plr.Character:WaitForChild(“HumanoidRootPart”)
or
plr.Character:FindFirstChild(“HumanoidRootPart”)

(i forgot to click on reply)

local players = game:GetService("Players") --player's service
local player = players.LocalPlayer --local player instance exists for local scripts immediately
local character = player.Character or player.CharacterAdded:Wait() --character may or may not exist so we should wait for it if necessary
local hrp = character:WaitForChild("HumanoidRootPart") --even when the character has been added its descendants may not have replicated yet so we should wait for those too