RemoteEvent isn't firing/receiving only when playing on roblox

You can write your topic however you want, but you need to answer these questions:

  1. I need this RemoteEvent to fire

  2. It’s either not firing or receiving correctly for some reason
    In a team test
    image
    In roblox
    image Server log

    Client log

  3. I don’t really know what to change

The module script in ServerScriptStorage

local pickup = {}

function pickup.pickup (player, Item,messaparent)
	print(player.otherstuff.carry.Value ,player.otherstuff.carrymax.Value)
	local Pack = player.Backpack
	if player.otherstuff.carry.Value < player.otherstuff.carrymax.Value then
		local storage = game:GetService("ReplicatedStorage")
		local stat = storage:WaitForChild("StatUpdate")
		print(stat.Name)
		local ClonedItem = Item:Clone()
		ClonedItem.Parent = Pack
		player.otherstuff.weight.Value += ClonedItem.Weight.Value
		player.otherstuff.carry.Value += ClonedItem.Stack.Value
		stat:FireClient(player)
		messaparent:Destroy()
	end
end

return pickup

The Local script in StarterPlayerScript

local player = game:GetService("Players")
local mefr = player.LocalPlayer
local character = mefr.CharacterAdded:Wait()
local humanoided = character:FindFirstChild("Humanoid")
wait(1)
local otherstuff = mefr:WaitForChild("otherstuff")
local weight = otherstuff:WaitForChild("weight")
local speedup = otherstuff:WaitForChild("speedup")
local humanoided = character:WaitForChild("Humanoid")
local storage = game:GetService("ReplicatedStorage")
local stat = storage:WaitForChild("StatUpdate")

stat.OnClientEvent:Connect(function()
	print("the pain is over")
	local speed = (16 + speedup.Value) - (weight.Value/5)
	humanoided.WalkSpeed = speed
end)
2 Likes

Was the item you want to clone created on the client? If so, the server may not have access to it. You may want to set it up in such a way where the server creates the item and set its network ownership to the player, or maybe add a tag/value/attribute into the item.

Or maybe it could be studio being funny with ServerStorage/ScriptService. Clients can’t use modules stored in ServerScriptService or ServerStorage without a bunch of hacky fiddling (although ServerScripts can call from RepStorage/RepFirst).

Either way, I did notice a couple of things that could cause some issues outside of the main one you’re having also.

Module:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local statUpdate = ReplicatedStorage:WaitForChild("StatUpdate")
-- better to keep these in memory toward the top so the script doesn't have to
-- fetch the service and the event every time the function runs.
-- This can save a bit of overhead when running the function a bunch for many players.

local pickup = {}

function pickup.pickup (player, Item, messaparent)
	print(player.otherstuff.carry.Value ,player.otherstuff.carrymax.Value)

	if (player.otherstuff.carry.Value + Item.Weight.Value) > player.otherstuff.carrymax.Value then
		print("Carrying too much to pick up more!")
		return
		-- exits the function early so nothing runs unnecessarily
		-- if player is carrying too much.
	end

	local Pack = player.Backpack

	print(stat.Name)

	local ClonedItem = Item:Clone()
	ClonedItem.Parent = Pack
	player.otherstuff.weight.Value += ClonedItem.Weight.Value
	player.otherstuff.carry.Value += ClonedItem.Stack.Value

	stat:FireClient(player)

	messaparent:Destroy()

end

return pickup

Other than that, I can’t really tell what could be going wrong. I’ll keep this post bookmarked if anything comes to mind, if nobody else can solve it before/if that happens lol

2 Likes

When the server script runs, does the cloned item still go into your bag? The only real think I can maybe logic in my head is that it’s firing to the wrong player (which wouldn’t be a problem in studio because you’re the only player). Try test-swapping stat:FireClient(player) with stat:FireAllClients() in a testing server away from your main game and see what happens.

1 Like

I implemented your change and it still doesn’t work

The module script is being fired from a script inside of the workspace

It does still go into my inventory
I tried what you suggested and it still doesn’t work

Since you’re changing the value of the player’s weight on the server, why not try and cut out the RemoteEvent and just update their walking speed on the server side as well?

1 Like

I’ll try doing that
I’ll update you once I finish

IT WORKED
Thank you so much!!!

1 Like

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