okay so, i got a little problem on my hands when it comes to tweening the humanoidrootpart.
you see, im trying to tween the rootpart so it could go down the black hole, (you’ll see in the video), and instead of going into the black hole, the rootpart decides to tween all the way back to the spawn.
this is so weird man…
look:
here is the code for tweening the rootpart too:
local plr = game:GetService('Players').LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local ts = game:GetService('TweenService')
local musichandle = require(plr.PlayerScripts.Player.Music)
local hrp = chr:WaitForChild('HumanoidRootPart')
local hum = chr:WaitForChild('Humanoid')
local downward = ts:Create(hrp, TweenInfo.new(2), {CFrame = hrp.CFrame * CFrame.new(0,-3,0)})
local swordareas = {
Area1 = 'SwordArea1'
}
hum.Touched:Connect(function(obj)
if (obj:IsA('Part') and obj.Name == swordareas.Area1) then
local tpenabled = obj:WaitForChild('TPEnabled')
obj.Plate.CanCollide = false
if tpenabled.Value ~= false then
tpenabled.Value = false
hrp.CFrame = CFrame.new(hrp.CFrame.Position) * CFrame.Angles(0, 0, 0)
hrp.Anchored = true
musichandle:StopMusic()
downward:Play()
end
end
end)
how could i solve this issue? is it something im doing wrong, or maybe it could be another script? please let me know, thank you.
if you need any other materials on how to solve this issue, please let me know too.
you’re only creating the downward tween at the top, and its goal {CFrame = hrp.CFrame * CFrame.new(0,-3,0)} is only calculated at the time of initialization (uses whatever the RootPart’s CFrame is whenever the variable is created)
you can fix this by creating it only whenever you need to tween them
local plr = game:GetService('Players').LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local ts = game:GetService('TweenService')
local musichandle = require(plr.PlayerScripts.Player.Music)
local hrp = chr:WaitForChild('HumanoidRootPart')
local hum = chr:WaitForChild('Humanoid')
local swordareas = {
Area1 = 'SwordArea1'
}
hum.Touched:Connect(function(obj)
if (obj:IsA('Part') and obj.Name == swordareas.Area1) then
local tpenabled = obj:WaitForChild('TPEnabled')
obj.Plate.CanCollide = false
if tpenabled.Value ~= false then
tpenabled.Value = false
hrp.CFrame = CFrame.new(hrp.Position)
hrp.Anchored = true
musichandle:StopMusic()
local downward = ts:Create(hrp, TweenInfo.new(2), {CFrame = hrp.CFrame * CFrame.new(0,-3,0)}) -- moved this line
downward:Play()
end
end
end)