#why wont the model move

1 messages · Page 1 of 1 (latest)

dark echo
#

so basically whenever i try to move this crab model with tweenservice, it just doesnt work, saying Position is not a valid member of Model, and if i move the hitbox, it only moves the hitbox.
besides the beautiful art of the crab, whats the issue with this
(also you prolly dont have to read through this anyways)

local ts = game:GetService("TweenService")
local runService = game:GetService("RunService")

local db = false
local crab = script.Parent

local function move()

    if db == true then
        return
    end

    local players = game.Players:GetPlayers()
    local count = 0

    local allPos = {}

    for _, v in pairs(game.Players:GetChildren()) do
        count += 1

        local plrModel = game.Workspace:FindFirstChild(tostring(players[count]))
        local posPlr = plrModel.HumanoidRootPart.Position

        local mag = (posPlr - crab.Position).Magnitude
        table.insert(allPos, mag)
    end

    local curLowest = 0
    local count = 0
    local lowPos = 0

    for _, v in allPos do
        count += 1
        if curLowest ~= 0 then
            if v < curLowest then
                curLowest = v
                lowPos = count
            end
        else
            curLowest = v
            lowPos = count
        end

    end

    local target = game.Workspace:FindFirstChild(tostring(players[lowPos])) --
    local speed = 50
    local mag = curLowest
    local t = mag / speed 

    local endPos = {Position = target.HumanoidRootPart.Position}
    local moveTween = ts:Create(crab, TweenInfo.new(t, Enum.EasingStyle.Linear), endPos)
    moveTween:Play()
    wait(0.5)

end

runService.Heartbeat:Connect(move)
swift oasis
#

local ts = game:GetService("TweenService")
local runService = game:GetService("RunService")

local db = false
local crab = script.Parent

-- Make sure the crab has a PrimaryPart set in the model settings
-- Or do it in code:
crab.PrimaryPart = crab:WaitForChild("Hitbox") -- or the main body part

local function move()
if db then return end
db = true

local players = game.Players:GetPlayers()
local closestPlayer = nil
local closestDistance = math.huge

for _, player in ipairs(players) do
    local char = workspace:FindFirstChild(player.Name)
    local hrp = char and char:FindFirstChild("HumanoidRootPart")
    if hrp then
        local dist = (hrp.Position - crab.PrimaryPart.Position).Magnitude
        if dist < closestDistance then
            closestDistance = dist
            closestPlayer = hrp
        end
    end
end

if closestPlayer then
    local speed = 50
    local time = closestDistance / speed

    local goal = {
        CFrame = CFrame.new(closestPlayer.Position)
    }

    local tween = ts:Create(crab.PrimaryPart, TweenInfo.new(time, Enum.EasingStyle.Linear), goal)
    tween:Play()
end

task.wait(0.5)
db = false

end

runService.Heartbeat:Connect(move)

pseudo sage
dark echo
#

was this made by chatgpt

swift oasis
#

Sure was lol

dark echo
#

ok thx pyro but

#

its made of multiple thingies

#

1 sec

thick gateBOT
#

studio** You are now Level 5! **studio

swift oasis
#

Scientific statement

dark echo
#

gonna change parent things soon

pseudo sage
dark echo
#

ooohhhhhhh i forgot about contraints

#

thx

dark echo
#

the other things dont move

#

is it something to do with the fact that its being tweened?

pseudo sage
dark echo
#

nope

#

still dont work

pseudo sage
#

add prints to prove code is running

#

coz its probably not running

dark echo
#

no like the primary part is moving

#

but onlt that part

#

only*

pseudo sage
#

ya maybe ur constraints not active

dark echo
#

double checked and they are active

pseudo sage
#

are you tweening position or cframe? it should be cframe

dark echo
#

o ok

#

now it works and it also does rotation

#

yay

swift shoal
# dark echo now it works and it also does rotation

I'll assume that it rotates to 0,0,0. If so, then that's because you're telling it to just tween to a cframe, with no rotation information given. You can have it keep it's current orientation by just multiplying it times the crab.primarypart's CFrame rotation

dark echo
#

no but like i want the rotation tho

#

sry to shut u down here

swift shoal
#

Well, if you use a mul op on 2 CFrames, then it will combine the CFrames. If the "goal cframe"'s rotation= the crab's current rotation, then it doesn't spin

#
  local goal = {
            CFrame = CFrame.new(closestPlayer.Position) * Crab.PrimaryPart.CFrame.Rotaton
        }```

should work, yet @pseudo sage may tell me about .Rotation not returning in radiants, as that does sound like some stupid thing that roblox has added in it's engine. CFrames for me is always just trying out theories and then seeing if they actually return info in the rights units 😆
#

Hang on, why am I unable to comprehend fucking English

#

I fully misread that second to last sentence he wrote...

swift oasis
#

weird

swift shoal
dark echo
#

you rly remind me of some1 else ik irl

pseudo sage
# swift shoal ```lua local goal = { CFrame = CFrame.new(closestPlayer.Position) ...

i always get confused on which units to use too ;p fortunately there's only 2 possibilities and it's fairly obvious fairly fast if you're using the wrong one. just be thankful this is just a silly little roblox game and not a multi-million dollar satellite hehe https://en.wikipedia.org/wiki/Mars_Climate_Orbiter#Cause_of_failure

The primary cause of this discrepancy was that one piece of ground software supplied by Lockheed Martin produced results in a United States customary unit, contrary to its Software Interface Specification (SIS), while a second system, supplied by NASA, expected those results to be in SI units, in accordance with the SIS. Specifically, software that calculated the total impulse produced by thruster firings produced results in pound-force seconds. The trajectory calculation software then used these results – expected to be in newton-seconds (incorrect by a factor of 4.45)[2] – to update the predicted position of the spacecraft.[2]

The Mars Climate Orbiter (formerly the Mars Surveyor '98 Orbiter) was a robotic space probe launched by NASA on December 11, 1998, to study the Martian climate, Martian atmosphere, and surface changes and to act as the communications relay in the Mars Surveyor '98 program for Mars Polar Lander. However, on September 23, 1999, communication with ...

dark echo