Hi, new to using the site but I've been looking at it for help a lot, so thanks to everyone here in advance!

So I'm trying to learn more scripting, and right now I'm working on learning remote events. I took some example scripts from the ROBLOX Developer help article to try and mess around with it and learn, so i decided to try and make it so when the remote event is fired from the local script in the client the server script will clone a tool and place it into the player's backpack but it isn't working.

Every time it happens the print says nil, and tool just disappears. I can put it into the player itself, but it cant access the backpack.

I assume this has to do with server and client being unable to interact without remote events, but I'm sorta stuck on how I go about making it work. I even looked at some scripts at a friend's game and his actually work relatively similar, if not basically the same so I tried making it like his and still no luck.

Any solutions and better explanations of how this stuff works?

-- Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local createPartRequest = Instance.new("RemoteFunction")
--local Players = game.Players
createPartRequest.Parent = ReplicatedStorage
createPartRequest.Name = "CreatePartRequest"

local function onCreatePartRequested(player)
print(player.Name, "wants a sword")
local newerPart = game.ServerStorage.Zweihander:clone()
newerPart.Parent = player.Backpack
end

createPartRequest.OnServerInvoke = onCreatePartRequested

    -- LocalScript, different script idk this site im sorry lol

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartRequest = ReplicatedStorage:WaitForChild("CreatePartRequest")

local onCreatePartRequested = createPartRequest:InvokeServer()
print("The server created this part for me:", onCreatePartRequested)

Sorry if I messed up the format, I'm new to the site and again it's basically just a modification of the example scripts to help me figure out remote events. Sorry if I just missed something on the help article that fixes that, I'll be rereading it again.

Thanks!

3 comments

0

i messed up the code format thing on the post so i redid it, my bad lol

0

just fire the client from the server by createPartRequest:FireClient()

0

Use a remote event instead