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

RemoteEvent not firing?

The local script works completely fine, the prints and such work. The server script print does not print. This is very confusing as this should be correct and is very important to my scripts. There are no errors or yields in the output.

--Server script

game.ReplicatedStorage.DeadBodyItemCreate.OnServerEvent:Connect(function(plr, corpse, item)
		print('Recieved')
		local Wcorpse = workspace:WaitForChild(corpse.." Corpse").Inventory:WaitForChild(item)
		Wcorpse.Value = Wcorpse.Value - 1
		local plrItem = plr.Inventory:WaitForChild(item)
		plrItem.Value = plrItem.Value + 1
	end)

--Local script

local item = script.Parent.Parent.Parent
	local ItemName = item.Name
	local amount = item.ItemCount.ItemValue
	local CorpseName = item.Parent.Parent.PlayerName.Value
	print(CorpseName)
	game.ReplicatedStorage.DeadBodyItemCreate:FireServer(CorpseName, ItemName)
	print(CorpseName.." Corpse")

all of the values are correct. The server script is inside ServerScriptService, and the local script is inside a startergui. https://imgur.com/9vbpkPo that is the picture of the local script (at the bottom)

3 comments

0

Try making sure nothing is yielding the script before the OnServerEvent.

0

Well isn't the server responsible for what happens? Meaning when the client dies, it should fire. Try "OnClientEvent"? If I'm wrong then sorry.

0

Did you ever solve this issue? I'm having the same problem, everything in my code is correct in syntax but it won't fire to the server. No errors in output and all of the buttons work other than the FireServer part.

1 answer

Okay, so it's almost just fine, but there's just one problem. I think it's kind of stupid that it has to be like this, but when you're firing a server, you have to put in all the parameters as something, or else it won't work. If you don't need a certain parameter for something, then if possible, just remove it in the server script, otherwise just put it as nil in the :FireServer().

Here's how it would look:

Local:

local item = script.Parent.Parent.Parent
local ItemName = item.Name
local amount = item.ItemCount.ItemValue
local CorpseName = item.Parent.Parent.PlayerName.Value
print(CorpseName)
game.ReplicatedStorage.DeadBodyItemCreate:FireServer(CorpseName, ItemName,nil) -- There was 3 parameters in the .OnServerEvent, so you need to include three different variables in the fire server.
print(CorpseName.." Corpse")

The server would remain the same unless you were to remove the third parameter, then you would just have 2 in the local one too. Basically, to sum it up, you need to have the same amount of variables in the fire server as parameters in the .OnServerEvent.

Hope I helped!

1 comment

0

Nah the client sends player automatically so he has 3 there already.

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