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

RemoteEvent Script. Works in studio, but not in actual server?

Well, Basically I tried to follow the "RemoteFunction and RemoteEvent Tutorial" Roblox offered. And I ended up with this script in 'ServerScriptService' with another script in that script. I'm not 100% sure about how Server and Local Scripts go in this process. But I got it to work in studio. May I also mention, I have Filtering Enabled Turned ON.

Here is the Server Script [According to What I thought]:

wait(5)
local event = Instance.new("RemoteEvent") 
event.Parent = game.Workspace 
event.Name = "LeftDoorEvent"

event.OnServerEvent:connect(function()
	local Door = game.Workspace.LeftDoor1
	local main = Door:GetPrimaryPartCFrame()
	local part = Door.PrimaryPart
	local clic = Door.ClickDetector
	local sound = Door.Sound 
	if Door.Open.Value == 1 then 
		sound:Play()
		local fix = Door.Main.CFrame 
	for i = 0,1.5,0.1 do
		wait(0.05)
		Door:SetPrimaryPartCFrame(Door.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25))
		Door.Open.Value = 0
		clic.MaxActivationDistance = 0
	end
		Door:SetPrimaryPartCFrame(fix*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5))
		wait(0.25)
		clic.MaxActivationDistance = 15
	elseif Door.Open.Value == 0 then
		sound:Play()
		local fix = Door.Main.CFrame 
	for i = 0,1.5,0.1 do
		wait(0.05)
		Door:SetPrimaryPartCFrame(Door.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25))
		clic.MaxActivationDistance = 0
	end
		Door:SetPrimaryPartCFrame(fix*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5))
		wait(0.25)
		clic.MaxActivationDistance = 15
		Door.Open.Value = 1
	end 
end)

The Script above activates once the door is clicked from a ServerEvent

This next script is what Roblox called "The Local Script"

wait(5)
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = game.Workspace.LeftDoor1
clickDetector.MouseClick:connect(function(hit)
	game.Workspace.LeftDoorEvent:FireServer()
end)

The above script is suppose to fire the server thing and cause the door to move. Which activates the server script. This script is a Child of the ServerScript.

I do not understand the problem. Maybe I formatted something wrong, or the scripts are the wrong type, or in the wrong location?

ServerScript:IsA - regular Script just in ServerScriptService LocalScript:IsA - regular Script and its parent is the ServerScript.

1 answer

Your problem is that the 'local script' has to be an actual LocalScript!

Additionally, LocalScripts won't run except in:

  • The Workspace as a descendant of the LocalPlayer's Character Model.
  • The LocalPlayer's PlayerGui.
  • The LocalPlayer's Backpack.
  • The LocalPlayer's PlayerScripts.
  • ReplicatedFirst

The middle three have associated 'Starter' containers as well: StarterGui, StarterPack, and StarterPlayerScripts (although this one is a descendant of the Players Service.)

Putting the LocalScript directly in one of these containers will work for you.

2 comments

0

okay ill try it out thanks!

0

This again, only worked in studio. I'm so confused!

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