Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My sword doesn't show up on other players screen??? , need help

Asked by
TeamOJ 2
4 years ago
Edited by theking48989987 4 years ago

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)
0
without code, im gonna have to go on a limb here, but try researching Network Filtering / Filtering Enabled theking48989987 2147 — 4y
0
it has to be given to them with a server script so use a remoteevent from the local script TypicallyPacific 61 — 4y
0
How would i do that ? , i'm still new to scripting TeamOJ 2 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
`Event` is an event of a bindable event, not a RemoteEvent theking48989987 2147 — 4y
0
oops Dudeguy90539 36 — 4y
0
my bad, i didnt make this code in a script editor Dudeguy90539 36 — 4y
0
thanks you so much and its okay TeamOJ 2 — 4y
Ad

Answer this question