Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

3 comments

0

without code, im gonna have to go on a limb here, but try researching Network Filtering / Filtering Enabled

0

it has to be given to them with a server script so use a remoteevent from the local script

0

How would i do that ? , i'm still new to scripting

1 answer

✓ Accepted answer

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.

4 comments

0

Event is an event of a bindable event, not a RemoteEvent

0

oops

0

my bad, i didnt make this code in a script editor

0

thanks you so much and its okay

This discussion is preserved as it was. New answers, comments, and votes are closed.