Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ym5a 52
3 years ago
Edited 3 years ago


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

0
 .Position returns a vector3. JesseSong 3916 — 3y
0
Since you didn't specify, I thought the error was talking about the string "Position" JesseSong 3916 — 3y
0
Everything else looks fine except for root.Position. JesseSong 3916 — 3y
0
Replace line 40 with: local root = search:WaitForChild("HumanoidRootPart") JesseSong 3916 — 3y
View all comments (7 more)
0
let me know if it solved it, or if you still encounter an error JesseSong 3916 — 3y
0
@JesseSong I did it and got a warning: Infinite yield possible on 'Workspace.box:WaitForChild("HumanoidRootPart") ym5a 52 — 3y
0
i can't help you now, but the error is because humanoidrootpart is nil JesseSong 3916 — 3y
0
how do i fix it ym5a 52 — 3y
0
check my answer again, make sure you try it! JesseSong 3916 — 3y
0
@JesseSong I put your script in and replaced it with mine but still the same thing happens ym5a 52 — 3y
0
check my answer i finally solved it. also, if it works do some editing to your preference. JesseSong 3916 — 3y

2 answers

Log in to vote
1
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

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)
0
I want it to keep going to the players position, also I updated the question and script ym5a 52 — 3y
0
then you should use a loop JesseSong 3916 — 3y
0
@JesseSong still doesnt work https://prnt.sc/1ludq24 ym5a 52 — 3y
0
@JesseSong here i made a vid https://www.youtube.com/watch?v=spd_3pq0iaM ym5a 52 — 3y
Ad
Log in to vote
0
Answered by
ym5a 52
3 years ago
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

0
it worked for me. send a screenshot of where the part is placed JesseSong 3916 — 3y
0
https://prnt.sc/1lwvw21 here ym5a 52 — 3y
0
if you have more questions just comment JesseSong 3916 — 3y

Answer this question