What do you want to achieve?
FIx something for my game
What is the issue?
Fireserver not working correctly
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
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()
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 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.
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…
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)
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