Lol now that I can finally access studio can finally fix this problem I’m trying to make this payload push thing where if you’re in the circle it tweens the payload and if you’re not it stops and I seem to have gotten it working the only issue is I can’t seem to get the speed consistent. Whenever you walk in and out a bunch of times the tween seems to get slower and then goes back to normal when it reaches the next point? How can I always keep it moving at the same speed?
Here’s my coding
--| Modules |--
local Zone = require(SSS:WaitForChild("Zone"))
--| Constants |--
local PAYLOAD_MODEL = workspace:WaitForChild("Payload")
local PAYLOAD_RADIUS = PAYLOAD_MODEL.Model.Radius
local PAYLOAD_ZONE = Zone.new(PAYLOAD_RADIUS)
--| Variables |--
local Moving = false
local Deb = true
local Map = workspace.TestMap1
--| Payload Settings |--
local Speed = 20
local RotationSpeed = 1
--[[note
Current Issues:
- Gets slower each time tween plays
- Need to keep the player moving with the payload if standing on it instead of just sliding off
]]
local RachedNodes = {}
local CurrentNode = Map.Node
function MovePayload()
local ReachEnd = false
while Moving and ReachEnd == false do
warn("Moving to "..CurrentNode.Name)
local MovementInfo = TweenInfo.new(
Speed,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
MovementTween = TS:Create(PAYLOAD_MODEL.PrimaryPart,MovementInfo,{CFrame = CFrame.new(CurrentNode.CFrame.X,PAYLOAD_MODEL["Part"].CFrame.Y,CurrentNode.CFrame.Z)})
MovementTween:Play()
MovementTween.Completed:Wait()
if Moving then
local NextNode = CurrentNode:GetChildren()
if #NextNode > 0 then
CurrentNode = NextNode[1]
else
warn("Reached End")
ReachEnd = true
end
end
end
end
PAYLOAD_ZONE.playerEntered:Connect(function(Player)
if #PAYLOAD_ZONE:getPlayers() == 1 then
warn("Moving Payload")
Moving = true
MovePayload()
end
end)
PAYLOAD_ZONE.playerExited:Connect(function(Player)
if #PAYLOAD_ZONE:getPlayers() == 0 then
warn("Stopping Payload")
Moving = false
MovementTween:Cancel()
end
end)