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

How would I make this part of my script work in a server script, not just a local script?

I have a local script that I am trying to switch to a server script so everyone in the game can see it, not just the person that has it. This seems to be the only problem of the script that isn't working. I am trying to figure out what I need to change for it to work. (loudness is for playbackloudness, the parts are bouncing with the beat basically)

Server Script:

game:GetService("RunService").Heartbeat:connect(function()
	for i, v in pairs(game.Players:GetChildren()) do
 		for i = 1, #Parts do
   			if i == 1 then
     			Parts[i].CFrame = Parts[i].CFrame:lerp(v.Character.UpperTorso.CFrame, 0.9)
   			else
     			Parts[i].CFrame = Parts[i].CFrame:lerp(Parts[i - 1].CFrame * CFrame.Angles(-loudness / 20, math.sin(-loudness / 50), 0) * CFrame.new(0, 0, 0.15), 0.8)

			end
		end
	end
	for i, v in pairs(game.Players:GetChildren()) do
 		for i = 1, #Parts2 do
   			if i == 1 then
     			Parts2[i].CFrame = Parts2[i].CFrame:lerp(v.Character.UpperTorso.CFrame, 0.9)
   			else
     			Parts2[i].CFrame = Parts2[i].CFrame:lerp(Parts2[i - 1].CFrame * CFrame.Angles(-loudness / 20, math.sin(loudness / 50), 0) * CFrame.new(0, 0, 0.15), 0.8)
   			end
 		end
	end
end)

Here's the same part but from the Local Script i'm changing it from:

game:GetService("RunService").RenderStepped:connect(function()
 	for i = 1, #Parts do
   		if i == 1 then
     		Parts[i].CFrame = Parts[i].CFrame:lerp(game.Players.LocalPlayer.Character.UpperTorso.CFrame, 0.9)
   		else
     		Parts[i].CFrame = Parts[i].CFrame:lerp(Parts[i - 1].CFrame * CFrame.Angles(-loudness / 20, math.sin(-loudness / 50), 0) * CFrame.new(0, 0, 0.15), 0.8)
   		end
 	end
 	for i = 1, #Parts2 do
   		if i == 1 then
     		Parts2[i].CFrame = Parts2[i].CFrame:lerp(game.Players.LocalPlayer.Character.UpperTorso.CFrame, 0.9)
   		else
     		Parts2[i].CFrame = Parts2[i].CFrame:lerp(Parts2[i - 1].CFrame * CFrame.Angles(-loudness / 20, math.sin(loudness / 50), 0) * CFrame.new(0, 0, 0.15), 0.8)
   		end
 	end
end)

1 answer

Or you could make the localscript fire a Remote Event so that it’s on the server side

2 comments

0

When you write an answer it literally says "If you are not posting an explanation, please use comments instead!"

0

This is might be the answer

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