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

How do I fix this local part problem?

Asked by 8 years ago

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

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. AZDev 590 — 8y
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. Hero_ic 502 — 8y

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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^

Ad
Log in to vote
0
Answered by 8 years ago

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)
0
scan is a table of objects. JustAUslessAccount 5 — 8y

Answer this question