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)
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
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.
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?