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
7 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

tool = script.Parent.Parent



replicatedstorage = game:GetService("ReplicatedStorage")

tool.Selected:connect(function(mouse)
mouse.Button1Down:connect(function()
    local player = tool.Parent.Parent
        local lightning = replicatedstorage.RicoClass:findFirstChild("Lightning")
        local light = lightning:clone()

        light.Parent = player.Character
        light.Anchored = false
        light.CanCollide = false
        local w = Instance.new("Weld" ,light)
        w.Part0 = player.Character.RTIndexFinger
        w.Part1 = light
        w.C1 = CFrame.Angles(0,0,40)
        w.C0 = CFrame.new(0,0,0.2)
end)
end)

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 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;

local tool = script.Parent.Parent
local replicatedstorage = game:GetService("ReplicatedStorage")
local re = replicatedStorage:FindFirstChild("Lightning")
--^This is your remoteevent

tool.Selected:connect(function(mouse)
    mouse.Button1Down:connect(function()
        re:FireServer();
    end)
end)

Server script;

local replicatedstorage = game.ReplicatedStorage;

script.Parent.OnServerEvent:connect(function(player)
    local lightning = replicatedstorage.RicoClass:findFirstChild("Lightning")
    local light = lightning:clone()
    light.Parent = player.Character
    light.Anchored = false
    light.CanCollide = false
    local w = Instance.new("Weld" ,light)
    w.Part0 = player.Character.RTIndexFinger
    w.Part1 = light
    w.C1 = CFrame.Angles(0,0,40)
    w.C0 = CFrame.new(0,0,0.2)
end
0
This would be the right way of doing it. This is also compatible with FilteringEnabled shadownetwork 233 — 7y
Ad

Answer this question