Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My tween script only goes to where the player spawns how to fix it?



local man = script.Parent

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) 
	print('FIN')
	local parts = game.Workspace.box.bust:GetChildren()
	for i,v in pairs(parts) do
		v.Anchored = false
	end
	print("hi")
	wait(0)
	
	local tweenService = game:GetService("TweenService")
	local part = script.Parent


	local tweeningInformation =  TweenInfo.new(

		2,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.In,
		0,
		false,
		0)

	local tweeningProperties = {


		["Position"] = Vector3.new(-8.572, 17.175, 6.652);

	}


	local Tween = tweenService:Create(part,tweeningInformation,tweeningProperties)

	Tween:Play()
	man.Anchored = true

	Tween.Completed:connect(function()
		--local search = game.Workspace:FindFirstChildWhichIsA("Model")
		--local root = search:WaitForChild("HumanoidRootPart")
		repeat

				local part1 = script.Parent


				local tweeningInformation1 =  TweenInfo.new(

					0.5,
					Enum.EasingStyle.Linear,
					Enum.EasingDirection.In,
					0,
					false,
					0)

				local tweeningProperties1 = {


				["Position"] = Vector3.new(player.Character.HumanoidRootPart.Position); --player from the remoteevent client to server data transfer

				}


				local Tween1 = tweenService:Create(part1,tweeningInformation1,tweeningProperties1)

			Tween1:Play()
			print("lopp")
			wait(1)
		until script.Parent.clear.Value == true
	end)
end)

No errors but it just doesnt move from the spot where player spawned but print (lopp) like it should

11 comments

0

 .Position returns a vector3.

0

Since you didn't specify, I thought the error was talking about the string "Position"

0

Everything else looks fine except for root.Position.

0

Replace line 40 with: local root = search:WaitForChild("HumanoidRootPart")

0

let me know if it solved it, or if you still encounter an error

0

@JesseSong I did it and got a warning: Infinite yield possible on 'Workspace.box:WaitForChild("HumanoidRootPart")

0

i can't help you now, but the error is because humanoidrootpart is nil

0

how do i fix it

0

check my answer again, make sure you try it!

0

@JesseSong I put your script in and replaced it with mine but still the same thing happens

0

check my answer i finally solved it. also, if it works do some editing to your preference.

2 answers

✓ Accepted answer

##Problem: (Re-edited)

Everything's fine, the only thing is that you'll need some kind of loop for it to constantly follow the player.

##Solution: You can accomplish this, by adding a loop, I'm going to be using a while loop

##Script:


local man = script.Parent

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) 
	print('FIN')
	local parts = game.Workspace.box.bust:GetChildren()
	for i,v in pairs(parts) do
		v.Anchored = false
	end
	print("hi")
	wait(0)
	
	local tweenService = game:GetService("TweenService")
	local part = script.Parent


	local tweeningInformation =  TweenInfo.new(

		2,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.In,
		0,
		false,
		0)

	local tweeningProperties = {


		["Position"] = Vector3.new(-8.572, 17.175, 6.652);

	}


	local Tween = tweenService:Create(part,tweeningInformation,tweeningProperties)

	Tween:Play()
	man.Anchored = true

	Tween.Completed:connect(function()
		--local search = game.Workspace:FindFirstChildWhichIsA("Model")
		--local root = search:WaitForChild("HumanoidRootPart")
		repeat

				local part1 = script.Parent


				local tweeningInformation1 =  TweenInfo.new(

					0.5,
					Enum.EasingStyle.Linear,
					Enum.EasingDirection.In,
					0,
					false,
					0)

				local tweeningProperties1 = {


				["Position"] = Vector3.new(player.Character.HumanoidRootPart.Position); --player from the remoteevent client to server data transfer

				}


				local Tween1 = tweenService:Create(part1,tweeningInformation1,tweeningProperties1)

			Tween1:Play()
			print("lopp")
			wait(1)
		until nil
	end)
end)

4 comments

0

I want it to keep going to the players position, also I updated the question and script

0

then you should use a loop

0

@JesseSong still doesnt work https://prnt.sc/1ludq24

0

@JesseSong here i made a vid https://www.youtube.com/watch?v=spd_3pq0iaM

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
	print('FIN')
	local parts = game.Workspace.box.bust:GetChildren()
	for i,v in pairs(parts) do
		v.Anchored = false
	end
	local Player = game:GetService("Players").PlayerAdded:Connect(function(player)
		
	local Character = player.Character or player.CharacterAdded:Wait()
	while wait(3) do -- change it to the amount of secs you want it to wait

		local root = Character:WaitForChild("HumanoidRootPart")
		local tweenService = game:GetService("TweenService")
		local part = script.Parent
		part.Position = root.Position
		local tweeningInformation =  TweenInfo.new(

			2,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.In,
			-1,
			false,
			1)




		local tweeningProperties = {


			["Position"] = Vector3.new(-8.572, 17.175, 6.652);

		}


		local Tween = tweenService:Create(part,tweeningInformation,tweeningProperties)

		Tween:Play()
		part.Anchored = true

		Tween.Completed:connect(function()
			local search = game.Workspace:FindFirstChildWhichIsA("Model")
			local root = Character:WaitForChild("HumanoidRootPart")


			local part1 = script.Parent


			local tweeningInformation1 =  TweenInfo.new(

				0.5,
				Enum.EasingStyle.Linear,
				Enum.EasingDirection.In,
				0,
				false,
				1)

			local tweeningProperties1 = {

				["Position"] = Vector3.new(root.Position) --player from the remoteevent client to server data transfer


			}


			local Tween1 = tweenService:Create(part1,tweeningInformation1,tweeningProperties1)

			Tween1:Play()
			print("lopp")
			wait(1)
			end)
		end
	end)
end)

@JesseSong I edited the script a bit, but nothing happens except the wall falling

3 comments

0

it worked for me. send a screenshot of where the part is placed

0

if you have more questions just comment

This discussion is preserved as it was. New answers, comments, and votes are closed.