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

How do I fix this local part problem?

So when I make a part inside a local script it doesn't show the other player the part. How do I fix this?

2 comments

1

Can you explain this a little better? I do not understand what you are asking. I am almost certain that the others do not either.

1

I am certain you are using filtering enabled, if that is the case then anything made in a local script will not work for anyone else.

2 answers

You can use Remotes! :D

Remotes are RemoteEvents and RemoteFunctions. These provide client to server communication and are normally used for FilteringEnabled.

So, you need to use the FireServer function on a RemoteEvent in ReplicatedStorage. This will send a request to the RemoteEvent and if there are any OnServerEvent events listening, then they will fire upon recieving the request.

--Your RemoteEvent
local re = game.ReplicatedStorage.CreatePart

--Use the FireServer function on it
re:FireServer()

Note: This should be a localscript^

Now, you can have a script inside the remote event that creates the part. You need to use the OnServerEvent event to 'listen' for the FireServer request.

script.Parent.OnServerEvent:connect(function()
	--Create the part
	local p = Instance.new("Part",workspace)
	p.Size = Vector3.new(5,5,5);
	p.Anchored = true;
	p.CFrame = CFrame.new(0,10,0)
end)

Note: This should be a server script^

What would be wrong with this?

script.Parent.OnServerEvent:connect(function(Player,player,char,scan)
	for _,scan in pairs (scan) do
		if scan.ClassName == "Hat" or scan.Name == "Pants" or scan.Name == "Shirt" then	
			local clone = scan:Clone()
			clone.Parent = char
			if scan.ClassName == "Hat" then
				local weld = Instance.new("Weld",char.Head)
				weld.Part0 = char.Head
				weld.Part1 = clone.Handle
				weld.C0 = CFrame.new(0,0.5,0)
				weld.C1 = clone.AttachmentPoint
			end
		end
		if scan:FindFirstChild("face") then
			local clone = scan.face:Clone()
			clone.Parent = char.Head
		end
	end
end)

1 comment

0

scan is a table of objects.

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