Minecraft-like Sneak System

Hello, I am trying to make a system where you can’t fall off the edge in Roblox. It is similar to the sneaking system in Minecraft(https://minecraft.fandom.com/wiki/Sneaking). I am having trouble finding solutions to making this system. Could somebody help me?(Any help will be greatly appreciated.)

Thanks!

1 Like

Well, I could recommend an Idea which could potentially help with this.

So as a player presses/holds down a key bind, you’re animation plays which you will also have to get something to activate in order for the Server to recognize the event. From there the event would put walls around blocks to keep the player from falling off of it.

Then as/if the player lets go of the key bind, the activated value would be put back to false hiding the walls (you can go through them again) and the animation would stop as well.

1 Like

I’ll try this out, Thanks a lot for the help!

I have a question though, would all the players be able to collide into the wall or just the person that held down the key bind?

I would assume as long as you keep it within the LocalScript then it will only happen for that player.

1 Like

You can have a folder of walls in the workspace and change the CanCollide value of each one in a LOCAL SCRIPT. It has to be client-sided otherwise the other players who wanted to go off of an edge would not be able to. The animation would replicate from client to server.

1 Like

Okay thanks, I’ll try that out.

1 Like

Just a heads up, client animations replicate to the server automatically.

1 Like

Yes, but instances don’t which is the desired effect.

1 Like

Hey everybody, thanks for the help! Everything seems to be working right now, I will let you know if I find any other bugs or errors along the way.

1 Like

Hello, I have tried this method, but it doesn’t seem like the Local Script is running. Here is my code:

local RS = game:GetService("ReplicatedStorage")

local Event = RS:WaitForChild("CrouchEventServer")

local part = script.Parent

print("Testing if this is running")

Event.OnClientEvent:Connect(function()

     part.CanCollide = true

end)

I also placed this code inside the part(an image will be attached below), did I maybe misplace the script or is there another reasoning behind this?

Screen Shot 2021-08-05 at 5.48.28 PM

This script should be within StarterPlayerScripts or StarterCharacterScripts.

1 Like

It seems to be working now, thanks for the help!

1 Like

honestly its best to keep those walls client sided to prevent server lag

1 Like

Hey everyone, I’ve been testing out the new system for a couple days now. It seems to be working fine. There is one problem though, if I were to make a block placement system, how would I be able to implement the crouch system to it? An idea I have is to put walls around the blocks that will be placed and when the player presses the button for crouch, it will make the walls CanCollide = true. Is there any other ways of doing this?

You could store blocks in an array or table, and check where the borders of each set of things are.

1 Like

Minecraft-like R6 Crouching where the player cant fall of an edge of a part - Help and Feedback / Scripting Support - DevForum | Roblox

3 Likes

Thanks for the help, I’ll try read the code and understand it.

1 Like

Thanks again for the help!

300303

2 Likes