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

Why isnt my script showing up for other players?

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

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

1 comment

0

This would be the right way of doing it. This is also compatible with FilteringEnabled

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