Hello im making a project and one of the puzzles im making is a sliding puzzle however its having a problem that i dont know how to fix basically when i click play it works and all being able to move the pieces but the main problem is that it spawns in a complete different place from where it shows in studio when i click play, and if i move it manually it breaks and it shows it completed and you cant touch anything. Any help? here is the script
#Need help with a sliding puzzle
1 messages · Page 1 of 1 (latest)
i believe it has to be with the vector but i dont really know anyone can help :c?
Can you post the code as a code block instead of images?
send me a code
sorry my timezone is different
thats why i replied late
I dont have a good luau viewer on my phone, so i asked deepseek to just write it in its app code viewer 🫠, but it tought this
U are missing a function in the txt file 🫠
Do you ever move the puzle model?
The only thing i can think of is that the model pivot point is in the middle of nowhere
At somepoint you use model:moveTo() or model:PivotTo() and that causes unexpect behavoiur
oh you mean this?
oh whoops idk why is it at 4,4,1
Yeah that, try setting the pivot offset to zero and no primary part
Or just using a folder instead of a model
aight done let me try moving it
eh the script makes it spawn somewhere else instead of where i put it in studio
well idk whats causing this
atp ill just manually change the position from the script myself
The positioning is relative to the workspace origin rather than the puzzle model due to how the Position property is set and the coordinate system used. Here's why:
-
Absolute Positioning:
tile.Position = Vector3.new((x - 85) * tileSize, tile.Position.Y, (y + 57) * tileSize)- This sets the tile's position in world space (workspace coordinates)
- The calculation doesn't reference
puzzleModel's position, making it absolute rather than relative
-
Coordinate System:
- Roblox parts use workspace coordinates by default when setting
.Position - To position relative to the model, you'd need to:
- Get the model's CFrame (position + orientation)
- Convert local positions to world space using
modelCFrame * Vector3.new(x, y, z)
- Roblox parts use workspace coordinates by default when setting
-
Offsets Explained:
(x - 85)and(y + 57)are hardcoded offsets- These likely place the puzzle grid in a specific location in the workspace
- For a 5x5 grid (
gridSize=5), this centers tiles around:- X:
(3 - 85)*4 = -328(since middle tile x=3) - Z:
(3 + 57)*4 = 240
- X:
-
Why it works:
- The tiles are children of
puzzleModel, but their positions are set in world space - When the model moves, its children move with it (inheriting transform)
- The initial positions are calculated relative to world origin, not model origin
- The tiles are children of
To make it relative to the model, you'd need to:
- Add a reference part in the model (e.g.,
PuzzleOrigin) - Modify
setTilePosition:(Wherelocal origin = puzzleModel.OriginPart.Position tile.Position = origin + Vector3.new((x-3)*tileSize, 0, (y-3)*tileSize)3is half ofgridSize=5for centering)
The current approach is simpler but assumes:
- The model starts at a known position
- No rotation is applied to the model
- Tile Y-positions are preserved from their original placement
ai intensifies
I know, i know what the issue is, but too much text to write myself
Give my fingees a brake, is not easy to write that much text on a phone screen 😭
wat is the issue?
He had the coordinates hardcoded
Instead of being relative to the model
I tought his problem was that it was being placed in the wrong hardcoded position
there are no hardcoded coordinates, which is the problem, close enough i guess, the ai is close enough too
so then
oh nvm there are hardcoded coords, the image and the code are different
i can record myself in any case to show what happens when i click play and when i move it manually
you can't move it though
the ai explained this
yeah i know if i move the model manually once i click play it just breaks
one of the few occasions where it is correct
but if i leave it where it is, it spawns somewhere else
so ill just change the position inside the script
in studio it will show somehwere else but in game it will show where i want
it doesnt matter where you put it in studio ?
what makes you think it does?
i mean in its current state
i just told u
this would be a different problem to its position
which the ai also appears to have picked up on
it works perfectly if i dont move it
server script or localscript?
local
thought so, so yea ai not gonna pick up on that unless you know to ask. the parts dont exist yet on the client when this code runs. workspace instance streaming
see
if i change it manually from the script it works
if i move it from studio it breaks
honestly i dont mind if it shows somewhere else in studio
set the model's streamingmode to atomic
what does that do
magic. just do it
persistent would also work
i prefer atomic personally
huh WHAT it worked
like i moved it without the script and its there and it works
wow Tysm
wait for it...
I just assumed it was a server script 😔
wait for what
unless you already fixed the other 2 problems
yea that was 2 fold, one was instance streaming the other was hardcoded positions, and then you have clicks not working
anyway thank you a lot both of u
** You are now Level 5! **
Also what does rankers do?
i rate scripts for skill ranks #📃︱ranking-tickets
This server is so weird xd
it helps with the #💵︱hiring channels so you have some idea what people are capable of
Makes sense, which is the ratio of slop to good work of the submissions?
as you would expect
there are far more beginners than there are experts.
Interesting
How much would you crucify someone for doing that?
In a scale from 1 to 10
depends on your code, if you want to config that way it's fine. the only sin i see is Stadistics
Instead of using tables i use folders with objectValues with more folders, and just clone the folder for each object i want to create 😂, just so i can use typeof(sillyFolder) and so that two modules can use objects created by each other with out entering a require() recursion
skill issue
I mean, it cant be that much worse for performance, plus you can see objects structures with out neededing to enter any script 🤔
You also get the .changed event and its already replicated to the client so implementing UIs its easier
don't worry about performance, it doesn't really matter at your stage. just focus on working code
it's a very common misconception started by people who can't handle other people who want to learn how to make games
Yeah, but im the only one who does things like this? There must be a hyper awfull drawback to that method, the only thing i can think of is exploting, but if someone wanted to reverse engineer your game this barely hurts them 🤔
** You are now Level 8! **
no, everyone thinks like that.
it's sad
Auch
like this guy for example, who thinks performance and optimization is the be-all end-all of all programming, and decides to insult and mock me because they don't understand why performance should take a back seat to functional code https://discord.com/channels/448986884497211392/1381039650063253676
ironically if they had just set out to write their game instead of hyper-focusing on performance, they would already know how to do what they asked
that's why premature optimization is so bad, it stops you moving forward and learning new stuff
but y'know, to each their own 🤷
Interesting, well it was nice talking to u 😊 best of lucks
@south nexus@errant crownum might need help once more 😭
my puzzle isnt puzzling
this is the updated puzzle, basically what its supposed to do is that once all tiles are in order it activates the proximity prompt of another part but is not doing that for some reason 💔
here is the full picture and completed, the tiles are in order from 1 to 25, 25 being the blank tile one
look into cframe worldspace / objectspace
two options, you use cframe:PivotTo(Cframe:LookAt(postion_of_your_puzle, vector_where_you_want_it_to_look_at))
or you create a new cframe with newCframe = cframe:lookAt(same as before) and then loop trough all parts of the puzle and do part.cframe = newCframe:toWorldSpace(part.cframe)
vector_where_you_want_it_to_look_at this vector is the orientation you want the puzle to have
so if you want it to look towards the z direction, use vector3.zAxis