Firing A Remote Event Problem

local:

local plr = game:GetService("Players").LocalPlayer
local Disguisted = plr.Character.Values.Disguisted

script.Parent.Activated:Connect(function()
	if Disguisted.Value == false then
		game:GetService("ReplicatedStorage").Events.EquipMask:FireServer(plr)
		Disguisted.Value = true
	else
		game:GetService("ReplicatedStorage").Events.UnEquipMask:FireServer(plr)
		Disguisted.Value = false
	end
end)

server:

local RS = game:GetService("ReplicatedStorage")
local isahat

game:GetService("ReplicatedStorage").Events.EquipMask.OnServerEvent:Connect(function(plr)
	
	local BlueGnome = RS.Items.BlueGnome:Clone()
	BlueGnome.Parent = plr.Character
	BlueGnome.Motor6D.Part0 = plr.Character.Head
	
	
	for i, v in pairs(plr.Character:GetChildren()) do
		if v:IsA("Accessory") then
			isahat = false
			for j, desc in pairs(v:GetDescendants()) do
				if desc:IsA("Attachment") and desc.Name == "HatAttachment" then
					isahat = true
				end
			end
			if isahat then
				AccFolder = Instance.new("Folder", RS)
				AccFolder.Name = plr.Character.Name.. "'s Folder"
				v.Parent = AccFolder
			else
				
			end
		end
	end
	
	
end)

game:GetService("ReplicatedStorage").Events.UnEquipMask.OnServerEvent:Connect(function(plr)
	
	local BlueGnome = plr.Character.Head:FindFirstChild("BlueGnome")
	BlueGnome:Destroy()
	
	for i, v in pairs(AccFolder:GetChildren()) do
		if v:IsA("Accessory") then
			v.Parent = plr.Character
		end
	end
	
	
end)

I am sure the problem is on the server because I tried printing something on the client and that worked
but if I try to print something on the server nothing happens. (output is clear)

Does someone know whats wrong?

1 Like

Where is your Server Script located?

in the same tool as the local script

Is there any error in output ?

nope nothing appears in the output

You don’t need to pass plr argument.

doesnt change anything it still doesnt work

What doesn’t work?

the script just doesnt work? removing plr didn’t change anything

Is the Server script in ServerScriptService?

no its in a tool like the local script

putting it in serverscriptservice solved the problem. can you explain why?

Its because the script is running on the client only. When you have a script in ServerScriptService, its replicated on the server, its always there, running on the server.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.