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

BodyPosition not doing what it's supposed to be doing? - Help Requested

Asked by 5 years ago
Edited 5 years ago

So I'm making a Minigame called ColourSink. But I'm having a little trouble with BodyPositioning.

I've tried Vectors, CFrames and even Tweens. Neither would fix my situation. Vectors would instantly go to it's place, leaving me to fall into the Lava, where I'd sink in. CFrames wouldn't work as the script has to randomly choose a colour slab, and all of the slabs are in different positions, whilst the CFrame will only hold one value. Tweening wouldn't work because the Positioning was stuffing up and/or hard to script.

But BodyPosition caught my eye. I was looking through the Toolbox, looking for that obstacle in obbies where the is the Start Brick, End Brick and the moving brick between them, I found out it had a bodyposition. So I thought I could do that with the slabs, as it would work, be beneficial, smooth and would be easy to script. I also had no other ideas to make this coloursink, and I wouldn't just give up as I have spent around 6 hours total coding the minigame.

But the bodyposition isn't doing what it's supposed to do.

It's supposed to be moving a random brick up as the lava goes up aswell. But it's just saying a colour, waiting 6 seconds, then saying another, over and over again.

Here is my scripting, tell me if something is wrong with it.

local chosen = {}
local function getSlab(slabs)
    local n
    repeat
        n = math.random(1, #slabs)
    until not chosen[n]
    chosen[n] = true
    return slabs[n]
end
function colourS()
        slabs = game.Workspace.ColourSink.Slabs:GetChildren()
    for i = 0, 6, 1 do
    local slabChosen = getSlab(slabs)
    game.Workspace.ColourSink.Billboard.Part.SurfaceGui.TextLabel.Text = slabChosen.Colour.Value
        wait(2)
        slabChosen.BodyPosition.position = slabChosen.endpart.Position
        wait(4)
        slabChosen.BodyPosition.position = slabChosen.startpart.Position
    end
    end
0
Alright so it can also depend on the Part's Mass but why do you find tweening so hard for this, this seems like the perfect place for tweening Omega_bs 40 — 5y
0
also i really think you should tostring() that slabChosen.Colour.Value unless its already a string Omega_bs 40 — 5y
0
The tweening doesn't work since Position won't work. It gives me a Global Error(W001). Also what do you mean by string? Sorry, I forgot. TheOnlySmarts 233 — 5y
0
Like text string, in the sense at line 14 you set a TextLabel's Text to a slabChosen.Colour.Value if that Value's ClassName is Already a String you wont really have to worry about it but wrapping it in a tostring() would be cool beans Omega_bs 40 — 5y
View all comments (11 more)
0
wait how are you using tweens, can you show me how you use tweens on part positions? Omega_bs 40 — 5y
0
I'll try to clear out all the problems you have against tweens because this would be great for using TweenService, i'd do it client side but this seems fine Omega_bs 40 — 5y
0
I watched the AlvinBlox tutorial and the partProperties table I did TheOnlySmarts 233 — 5y
0
local partProperties = {slabChosen.Position = slabChosen.Position + Vector3.new(0, 4, 0) } and I did the TweenService:Create and stuff. TheOnlySmarts 233 — 5y
0
wait a second what is endpart within the chosen slab, is it a separate part? Omega_bs 40 — 5y
0
why does this seem unreasonably confusing, maybe because i dont really know how you made these, if you wish you can invite me to a TeamCreate but i'm going to be going off in a few minutes we can clear stuff up over there Omega_bs 40 — 5y
0
the end part is where the tween stops at. then goes back down to start part, where it starts at. wait so do u want me to invite u to a team create now or not? TheOnlySmarts 233 — 5y
0
you can invite me now, i'll join when im free i just need to know how this is all set up since im somewhat confused Omega_bs 40 — 5y
0
don't use body position if you have an anchored part , it will not work. Also, don't use the position property of an object either, as it takes into account collisions. theking48989987 2147 — 5y
0
but it'll fall down if i dont anchor it? TheOnlySmarts 233 — 5y
0
I've unanchored it and changed the BodyPosition values as they were too I guess glitchy, it all works fine, but it tilts and rotates if I'm on one side of the platform. How do I make it so that doesn't happen. TheOnlySmarts 233 — 5y

Answer this question