Why is the block changing positions on start? (PrismaticConstraint)

The block that you’re supposed to push in my game is changing positions, even though its position follows the constraint rules.

Screenshots:


(Before the game starts, in Studio)


(During test sessions)

1 Like

Is the PrismaticConstraint set to Servo, Motor, or No constraint?
It also looks like you don’t have LimitsEnabled. They show up as green discs on the axis of the PrismaticConstraint to show where the block will stop.

1 Like

It’s set to None, and no limits are meant to be enabled.

1 Like

Then when your character pushes it it will keep moving along that axis.

1 Like

Yes, that is how I’m meaning for it to work. There is also a script in the wedge, but that’s only for when the block touches it.

1 Like

And what does the script do when the block touches the wedge? Try giving all the details when you make your original post so people replying don’t have to ask all these questions.
Are there any Forces in the block?
Is the PrismaticConstraint level or is it sloped slightly?

1 Like

Sorry, I’ll give the details.
The PrismaticConstraint is completely straight, not using multiple axes.
The block to push (named ‘push’) has custom physical properties:

Properties

Density : 25
Friction: 0.2
Elasticity : 0.5
FrictionWeight/ElasticityWeight : 1

And the script changes the axis and sets the Part’s position to it’s own position to prevent physics errors.

Script
local switch = script.Parent

local function onTouch(otherPart)
	if otherPart.Name == "push" then
		otherPart.Slide.Attachment1 = switch.AttatchmentValues.Second
		
	end
end

(currently deactivated, as there is no :Connect for the Event of touching)

Have you tried the Run button in the Test tab, just to see what happens visually when the Part moves instead of waiting for the game to load when testing in the Play mode.

If your Attachments are aligned when you put them in there shouldn’t be an issue. Check on the View Constraints tool under the Show Welds tool in the Model tool tab. You should see a yellow arrow and an orange arrow when you select each attachment. If the arrows face the same direction you’re good. If they don’t you’ll see a red(?) arrow in an arc that warns of the misalignment.

2 Likes

The attatchment was facing the wrong way, thank you for your help.

And you don’t need to set the AttachmentValues to get it at the same Position with the script. That’s the whole reason for setting it up with the tools and using the Limits, the slider will move along that axis without messing with scripts like this.
If you don’t set your limits your player may be able to push it so far away they can’t get it back.

1 Like