Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make things move with local scripts? [SOLVED]

So I'm basically making this obby game with different worlds and stuff. For some reason, all of my levels/worlds are always lagging when I play it in roblox player, but not when I run it in the studio. I'm pretty sure this isn't a building problem because they only have around 400 parts.

Also, it's only the moving parts that lag, not player movement or anything.

Here's the script:

(Rotating script for hammer obstacles)

model = script.Parent
model.PrimaryPart = model.PrimaryP

while true do
	for i=1, 13, 1 do -- 1+2+...+12+13 = 90 degrees
		script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, math.rad(i)))
		wait()
	end
	wait(2)
	for i=1, 13, 1 do
		script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, math.rad(-i)))
		wait()
	end
	wait(2)
end

I did some research and apparently it's better if you put these in local scripts (currently are regular scripts). I'm not sure if this is the problem, but when I tried to put this in a local script, nothing moved.

4 comments

0

try and optimize your scripts, and add debounces to events like touched

0

ok i'll try that. Thanks!

0

Ok I implimented it. I don't think the problem is that the scripts aren't efficient, because it works in the studio.

0

I did some research on this before I asked the question, and apparently it might be that this stuff isn't in local scripts? I'm not sure if that is the problem.

1 answer

Nvm I figured it out, you're supposed to put the local scripts into the player or character scripts folder.

This discussion is preserved as it was. New answers, comments, and votes are closed.