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

Why isnt my script showing up for other players?

Asked by
rexpex 45
8 years ago

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

01tool = script.Parent.Parent
02 
03 
04 
05replicatedstorage = game:GetService("ReplicatedStorage")
06 
07tool.Selected:connect(function(mouse)
08mouse.Button1Down: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
View all 22 lines...

1 answer

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

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;

01local tool = script.Parent.Parent
02local replicatedstorage = game:GetService("ReplicatedStorage")
03local re = replicatedStorage:FindFirstChild("Lightning")
04--^This is your remoteevent
05 
06tool.Selected:connect(function(mouse)
07    mouse.Button1Down:connect(function()
08        re:FireServer();
09    end)
10end)

Server script;

01local replicatedstorage = game.ReplicatedStorage;
02 
03script.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.Part0 = player.Character.RTIndexFinger
11    w.Part1 = light
12    w.C1 = CFrame.Angles(0,0,40)
13    w.C0 = CFrame.new(0,0,0.2)
14end
0
This would be the right way of doing it. This is also compatible with FilteringEnabled shadownetwork 233 — 8y
Ad

Answer this question