How to Make a Part Sway?

That is a nice simple idea, however, I think it would not result in a sway but rather more of a swing.

1 Like

Why not just use a sine wave?

In a local script (if you don’t need the effects to be synced it is very easy to do.

local Cycle
RunService.RenderStepped:Connect(function (Delta time)
    Cycle += Delta time
end

Use the Cycle into sim.

For a swing you can add it to a bezier curve

I am really confused why are other models are swaying with the script without being angle-fixed. Some models that I tested on, works properly and can even rotate the parts and still sway without angle fix happening.

I did not use any other formats other than the free model scripts I tried to mess with, since I am building often, I didn’t have knowledge how to script properly (I’m sorry but I am trying). For now, I do not understand how the script you mentioned works. But I will try to learn more about it. Thank you for the idea, I’ll mess the script and try to give it the result needed.

UPDATE: I saw few tutorials and videos about sine waves in roblox studio, however, it wasn’t the exact way I was hoping for. I was looking for to how to enable rotation on the part given with the sway script. But either way, thank you for the idea.

No problem, I used that same script for a while, until I realized it probably wasn’t a good idea to have a bunch of the same script running. I wish I could help more but I’m very new to scripting myself, so I wouldn’t know how to edit it, so parts are not fixed on the axis, so you wouldn’t need more then one

if you’re updating leaves and such, I really recommend just to use windshake. if you want to know how it works, you can even read its source code but I’m guessing you just want something that works.

the point of something like windshake is to make it easier, so by trying to avoid it because it’s complicated you are making it even more difficult for yourself.

I also checked the post and it looks like it has a gui editor, which means no code.

That’s okay, thank you for you help and replies, much appreciated. I’ll try to use other plugins and watch some tutorials to get the sway working. Thanks again.

I tried using the windshake model not the plugin, and it currently didn’t work yesterday. I have watched some tutorials how to get it work and it didn’t work. But I’ll try again, since something must have been wrong with my application. I’ll post an update.

cool. if it doesn’t work I’ll give it a shot myself and see what the problem is.

1 Like

Hello, I tried it on again and watched a tutorial on YT on how to apply the WindShake Model Plugin. I did try it on my showcase and on to another game, however, it doesn’t seem to be working on the studio nor the game. Here is the YT video I followed: How to add Wind Effect to objects (roblox studio) - YouTube

I did the same things and the same models. Blank workspace, no other parts other than the baseplate, no scripts or anything. I don’t get it, I used the same script as showed, here is mine:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WindShake = require(ReplicatedStorage:WaitForChild("WindShake"))

local WindDirection = Vector3.new(0.5, 0, 0.5);
local WindSpeed = 20;
local WindPower = 0.5;

WindShake:SetDeFaultSettings({WindDirection, WindSpeed, WindPower})

WindShake:Init() --emit

I used this script put it in the server script service. The WindShake model plugin is in the Replicated storage, none of them are disabled. I also used the tag editor shown on the video, I literally double-checked that the parts I want to move are tagged in the WindShake tag. But when I run it on the studio, it doesn’t work, nor does the game.

How can I achieve the moving trees with WindShake?

tried it myself. it worked. see this line.

WindShake:SetDeFaultSettings({WindDirection, WindSpeed, WindPower})

you wrote SetDeFaultSettings, it should be SetDefaultSettings. a typo. also, try sending the error message next time. I could have figured this out without even testing it if I had the error :slightly_smiling_face:

image

1 Like

Thank you so much! I finally got it to work! Thank you for the correction, this helped a lot!

UPDATE: Although it works really well on the studio, I’m afraid that it doesn’t work really well on the game, the parts that were moving on the studio are barely moving at the game. Is there any other way to fix this? You can test the game here → MODEL TESTING - Roblox I don’t know if it’s my connection, device or the problem is really in the game. You can check it out if the problem is the same.

sorry for the late reply.

actually, on my computer I can see them moving. it obviously depends a lot on how good your computer or your internet is (my machine is pretty slow, but connection is fast). you might see performance differences between the studio and your game because as far as I’m aware, studio gives you a “local development server” which means it is both playing and running the roblox server from your own computer. connecting to your own computer is of course much faster than connecting to roblox’s so it might seem faster.

to fix this problem, don’t use a server script. use a local script if you’re not already. any visual effects should go in localscripts to prevent these connection issues.

if you want to run this on for example a phone, it might be better to leave this feature out to prevent lag but you should test and see how bad it gets first. if the wind just isn’t giving the effect you want in general, you can change the WindSpeed or WindPower. if you still have problems you might want to leave a reply on the module, he probably knows more than I do.

1 Like

Noted. Thank you so much for the help! I’ll test it on a mobile device as well, if it does have a problem in the script, I’ll have to look it up. Thanks!

1 Like

UPDATE: I gave a review on the game on mobile and it’s still choppy. I tried to take the script out in the server script and put it on workspace. However, the performance is still choppy. I also changed the Hz up and down and still got no results. Thus, making the conclusion of sending a reply on the module post.

Can i see the code that performs the swaying? I may be able to help.
(Also, there is a windshake plugin you could probably use to add wind instead, it is very cheap. You can find information about it on this post)

I didn’t continue on the swaying script anymore, instead, I used the windshake plugin. Although the windshake works on the studio, it’s choppy in-game though.

putting it into the workspace doesn’t solve anything. you may want to find out how to add a LocalScript.

if it works on some devices but not others like mobile, you don’t need to delete it. you’ll just need to add a settings button to turn it on and off, automatically detect their device and adjust it, or create separate places for desktop and mobile (in order of the best solution).

Noted. I’ll look up on how to do it, and try it later. Thanks!

UPDATE: It works! The LocalScript works perfectly on mobile and on PC. I am super happy about the results and it’s not choppy anymore. Anyways, you can check the progress again! → MODEL TESTING - Roblox

3 Likes