I built a sword and made a simple Gui to make it clone to my back pack when clicked but when my friends join we cant see each others swords we just see a animation , need help please thank you
local Me = game:service("Players").LocalPlayer Char = Me.Character Mouse = Me:GetMouse() Activate = false local frame = script.Parent.Parent.Parent.Frame for _,v in pairs(Char:children()) do if v:IsA("CharacterMesh") or v:IsA("Pants") or v:IsA("Shirt") or v:IsA("Hat") or v:IsA("ShirtGraphic") then v:Destroy() end end script.Parent.MouseButton1Down:connect(function() game.Lighting["Sword3"]:Clone().Parent = game.Players.LocalPlayer.Backpack frame.Visible = false end)
Put a script in serverScriptService or workspace. then put a remoteEvent in workspace called "Give"
in the script, put the following
game.Workspace:WaitForChild("Give").OnServerEvent:Connect(function(plr) game.Lighting:FindFirstChild("Sword3"):Clone().Parent = plr.Backpack end)
in your localscript, replace the line that says "game.Lighting["Sword3"]:Clone().Parent = game.Players.LocalPlayer.Backpack" with the following:
game.Workspace.Give:FireServer()
this will cause the Server to put the sword in the player's inventory, not the client. The difference between localscripts and server scripts, if you didnt already know, is that server scripts are run on the server, and actions made by said script are made on the server, thus everyone can see them and are affected by them. Localscripts' actions are made on the client (The user's device). changes made on the device are not sent to the server and affect only the device the localscript was used on. remoteEvents/remoteFunctions are valuable tools used to send messages between the server and the user's client.