Fireserver not working correctly

  1. What do you want to achieve?
    FIx something for my game

  2. What is the issue?
    Fireserver not working correctly

  3. What solutions have you tried so far?
    Yes, but i couldn’t find any

I tried tweening a humanoidRootPart to another part using FireServer()

On localscript i put:

local part = workspace.Part
local player = script.Parent
game.ReplicatedStorage.Event:FireServer(player,part)

On server side


local ts = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player,part)
local rootpart = workspace:FindFirstChild(""..player.Name..""):FindFirstChild("HumanoidRootPart")

local properties = {
part.Position
}
ts:Create(rootpart,tweeninfo,properties):Play()

Output:
‘Position is not a valid member of Player "Players.Officially_DarkBloxx’
But whenever i try switching player and part, it also counts part as the player

Provide some code or else no one can help you troubleshoot the issue.

3 Likes

I edited it now. I keep having this problem and don’t know how to fix it

Try this,

local tweeninfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player,part)
local rootpart = workspace:FindFirstChild(""..player.Name..""):FindFirstChild("HumanoidRootPart")

local properties = {
Position = part.Position
}
ts:Create(rootpart,tweeninfo,properties):Play()

you’re firing the remote with a player argument, replace it with

game.ReplicatedStorage.Event:FireServer(part)

In properties, specify Position (the rootpart’s position) to change to the other parts position.

Hm? the only thing that seems to be changed here is that ‘local ts = game:GetService(“TweenService”)’ got removed?

Ohhh really? I always thought that i should fire part AND player. Since i thought the game needed to know which player to fire. Let me check this out real quick!

So there are a few problems here. First, make sure that in your local code your part is named something unique.

Every default part is named “Part”. You have to define exactly which one you want the game to reference.
Here is the client-sided code, make sure it’s in a place where it can run, here I have it located in StarterPlayerScripts.

local part = workspace.UniquePartName
game.ReplicatedStorage.RemoteEvent:FireServer(part)

Next is the server side. I have this located in ServerScriptService.

local ts = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,part)
	local character = player.Character
	
	if character then
		local rootPart = character:FindFirstChild("HumanoidRootPart")
		
		local properties = {
			Position = part.Position
		}

		local tween = ts:Create(rootPart,tweeninfo,properties)
		tween:Play()
	end
end)

You can simple use Player.Character to get their avatar. Always double-check with an if statement, just to be 100% sure in rare cases where it gets fired as a player is spawning or respawning, etc.
If you are testing on game initialization make sure there is a 5-second wait on the client code so the tween does not try to run while the player is spawning.

I indeed just realized that the properties needed to be “Position = Part.Position” thank you.

I replace my script with the one you made. However, the player’s character still stays in place. Even if i anchor it. I don’t know if something’s wrong here.

It worked on my end. Give me 10 minutes and I’ll make a tutorial for you.

Basically im making a point-and-click game and the main ‘CameraPart’ which is the player’s camera: needs to be controlled by the client due to some issues not working on the server side. So i had to make it so that the character goes with it for other players to see you. The part having a specific name probably won’t be working since the client selects a part from a folder done by for i,v. I copied and pasted ur script and replaced it with mine. So i don’t know what the issue is here…

Try this on its own. If it works then its an issue with something else in your code.

I totally get this. However like i told in my other post: i select the part in a different way. Like this:

local parts = workspace.Folder
local ThePart = nil

for _,v in next, parts:GetChildren() do
if v [has a specific property] then
ThePart = v
break
end
game.ReplicatedStorage.Event:FireServer(ThePart)

Basically this is how i kinda did it.
I don’t think this changes anything but still
(i used an example in the first script in the topic)

If it’s an issue with the loop, try formatting it like this:

for _, object in ipairs(parts:GetChildren()) do
	if object.property then
		game.ReplicatedStorage.Event:FireServer(object)
		break
	end
end

Next is a C function built into Lua, (ipairs) is used for looping through arrays cleanly.

Hmm, this never had any problems. The part selection works totally fine. But the only problem is that the HumanoidRootPart just won’t tween to the part

Have you tried using the debugger? If so, when exactly does the code stop running?

Whenever it found the right part (if u meant the part selection)

Is the server receiving the event connection?