I made a script that clones a brick and welds it to the creator's hand.(RTIndexFinger is apart of a rig with fingers) The local script works fine but other players cant see the brick, only the person that uses the tool sees it. this is all in a local script
01 | tool = script.Parent.Parent |
02 |
03 |
04 |
05 | replicatedstorage = game:GetService( "ReplicatedStorage" ) |
06 |
07 | tool.Selected:connect( function (mouse) |
08 | mouse.Button 1 Down:connect( function () |
09 | local player = tool.Parent.Parent |
10 | local lightning = replicatedstorage.RicoClass:findFirstChild( "Lightning" ) |
11 | local light = lightning:clone() |
12 |
13 | light.Parent = player.Character |
14 | light.Anchored = false |
15 | light.CanCollide = false |
You need to replicate the parts to the server in order for everyone to see them.
Setup a RemoteEvent. Create the parts on the server. Tell the RemoteEvent when to fire using FireServer
in the localscript.
LocalScript;
01 | local tool = script.Parent.Parent |
02 | local replicatedstorage = game:GetService( "ReplicatedStorage" ) |
03 | local re = replicatedStorage:FindFirstChild( "Lightning" ) |
04 | --^This is your remoteevent |
05 |
06 | tool.Selected:connect( function (mouse) |
07 | mouse.Button 1 Down:connect( function () |
08 | re:FireServer(); |
09 | end ) |
10 | end ) |
Server script;
01 | local replicatedstorage = game.ReplicatedStorage; |
02 |
03 | script.Parent.OnServerEvent:connect( function (player) |
04 | local lightning = replicatedstorage.RicoClass:findFirstChild( "Lightning" ) |
05 | local light = lightning:clone() |
06 | light.Parent = player.Character |
07 | light.Anchored = false |
08 | light.CanCollide = false |
09 | local w = Instance.new( "Weld" ,light) |
10 | w.Part 0 = player.Character.RTIndexFinger |
11 | w.Part 1 = light |
12 | w.C 1 = CFrame.Angles( 0 , 0 , 40 ) |
13 | w.C 0 = CFrame.new( 0 , 0 , 0.2 ) |
14 | end |