Code doesnt replicate to server despite being in a script

im trying to do controls for my game but since module scripts dont replicate to server i put it in a local script that should replicate to the server yet it doesn’t replicate to the server

here’s my code:
LocalScript

local event = game.ReplicatedStorage.classEvents:WaitForChild("pilgrimmed")
local uis = game:GetService("UserInputService")

event:FireServer("WeldSword")

uis.InputBegan:Connect(function(input, gpe, chatting)
	if chatting then return end
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		event:FireServer("LMB")
	elseif input.KeyCode == Enum.KeyCode.One then
		event:FireServer("Backstab")
	elseif input.KeyCode == Enum.KeyCode.Two then
		event:FireServer("KingsSpin")
	elseif input.KeyCode == Enum.KeyCode.Three then
		event:FireServer("Parry")
	end
end)

Script
(for some reason, doesn’t print the any or plr.Name)

local event = game.ReplicatedStorage.classEvents:WaitForChild("pilgrimmed")
local pilgrim = require(game.ReplicatedStorage.classes:WaitForChild("pilgrimmed"))

event.OnServerEvent:Connect(function(plr, any)
	print(any)
	print(plr.Name)
	if any == "LMB" then
		pilgrim.LMB(plr.Character, workspace.Terrain)
	elseif any == "Backstab" then
		pilgrim.Backstab(plr.Character, workspace.Terrain)
	elseif any == "KingsSpin" then
		pilgrim.KingsSpin(plr.Character, workspace.Terrain)
	elseif any == "ParryButNotReally" then
		pilgrim.ParryOrSoYouThink(plr.Character, workspace.Terrain)
	elseif any == "WeldSword" then
		pilgrim.WeldSword(plr.Character)
	end
end)
1 Like

My first guess to why this wouldn’t be working is the lack of the game:GetService() function. The client side script will execute as soon as possible, meaning it could try to find your event before ReplicatedStorage loads.

Try replacing game.ReplicatedStorage with game:GetService("ReplicatedStorage") in your client script. (Although it’s best practice for both server and client to call this function as opposed to using dots)

If this doesn’t work, try placing your server script in ServerScriptService.

1 Like

Is the WeldSword event firing successfully?

If not: Where is the local script located?

makes no difference if you do that
ReplicatedStorage always exists

1 Like

turns out i put the script in serverstorage after mistaking it for serverscriptservice, and then that unorganized everything

root of the problem: im blind

1 Like

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