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

Why does this script only work in studio but not player (Filtering Enabled)?

script.Parent.RemoteEvent.OnServerEvent:connect(function(a)
	warn("A")
	intValue = script.Parent.Parent.TextLabel.Integer
	intValue.Value = intValue.Value+1
	script.Parent.Parent.TextLabel.Text = intValue.Value
end)

2nd script:

script.Parent.MouseButton1Click:connect(function()
	print("a")
script.Parent.RemoteEvent:FireServer(a)
end)

If FE is enabled, this works in studio but not in in the player. If FE is disabled, it works in both. I can't find the problem,because I am getting no errors from the output. With FE enabled, the warn does not warn.

5 comments

0

are there any errors in the output?

0

^ He literally said he is getting no errors from the output.

0

lol rip

0

Send a picture of your stuff. I don't know what those parents are so..

2 answers

✓ Accepted answer

Server Script do not work in Client Locations. This includes StarterGui and PlayerGui. You attempted on placing the ServerScript in the TextButton and you made no attempt of cloning it to a Workspace or any other Server Communicating location. Consider placing the Server Script in Workspace.

Remote Events are usually placed in ReplicatedStorage simply because both Client and Server can access them. In your case, you implemented in the strictly client location that is StarterGui. Consider placing most of your Remote Event in ReplicatedStorage.

Client Script

-- [Declaration Section]
-- //Game Services 
local Player = game:GetService("Players").LocalPlayer;
local ReplicatedStorage = game:GetService("ReplicatedStorage");

local PlayerGui = Player:WaitForChild("PlayerGui");

-- //Remote Event Location
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");

-- //Button Location
local ScreenGui = PlayerGui:WaitForChild("ScreenGui");
local TextButton = ScreenGui:WaitForChild("TextButton");

-- [Processing Section

Click = function()
	RemoteEvent:FireServer();
end;

-- [Output Section]
TextButton.MouseButton1Down:Connect(Click);

Remote Event in ReplicatedStorage

Server Script

-- [Declaration Section]
local ReplicatedStorage = game:GetService("ReplicatedStorage");

-- //Remote Event Location
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");

-- [Processing Section]
OnSevEvent = function()
	print("I was called");
end;

-- [Output Section]
RemoteEvent.OnServerEvent:Connect(OnSevEvent);

Should you have any questions, feel free to comment below.

2 comments

0

Thanks!

0

No problem.

:connect() is deprecated, C should be in capital, :Connect

1 comment

0

I tried it and it did not work.

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