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

How to use Instance.new to summon a part everyone sees?

I tried using instance .new but for some reason nobosy else can see it, HOW!?!?!? I SUMMONED IT IN WORKSPACE! ONLY THE USER DOING THE SCRIPT CAN SEE IT!?!!? BUT HOW?

script

local w = game.Workspace

z = Instance.new("Part",w)
		z.CFrame = script.Parent.Parent.Character.Head.CFrame + script.Parent.Parent.Character.Head.CFrame.upVector * -.3 + script.Parent.Parent.Character.Head.CFrame.lookVector * 2
script.Mesh:Clone().Parent = z
z.Size = Vector3.new(.15,.15,.15)
z.Material = "Neon"
z.BrickColor = BrickColor.new("Cool yellow")
z.Anchored = true
z.CanCollide = false

WHY CAN ONLY USER SEE IT!?!??? (it uses chat to call this script)

4 comments

0

it is in a local script, maybe thats thr problem

0

yes that's the problem, create it via the server

0

Please read my answer, don’t accept, it won’t necessarily fix your issue, but you must know this

0

@Feahren makes you die inside, doesn't it?

3 answers

✓ Accepted answer

I GOT IT! i tested myself, so if script is in starterplayerscripts which i think you did because most people make that mistake, then its local (only that player) just put script in starterPack and dont change script or components inside it, since script.Parent.Parent.Character is still valid. Hope this answers :)

1 comment

0

OMG THX SO MUCH, IT WORKS

#Something to take away


#Reasoning

This is quite clear why only the LocalPlayer can see the Part created, it’s because of FilteringEnabled. If you’re unaware of this, it’s not good, It’s alright if you are new to ROBLOX’s Lua API, but this has been around for about two years, it is manditory you have a knowledge on how this works.

Please try to find more about this, also watch this to get a good understanding before continuing with more work.


#A brief rundown

This is because FilteringEnabled tells the Server to absolutely, never, trust the Client. The Client is your Computer.

Anything you do, will not be replicated to the Server, which replicates to all the other Clients - Players. Therefore when you created a Part on your end of the Server, it was told to not do the same for everybody else, primarily to prevent possible exploitation.


For the Server to replicate the Part to the other Clients, it must be done on the Server. Doing so isn’t hard at all, simply run the Instance.new function in a ServerScript, located in ServerScriptService.


This may be tough to continue attempting to do what your Code is running, as the Server cannot access the Client, therefore you can’t mess with the Player the way your Script appears to be doing.

You can get approved access though by loopholes. Those can consist of either traversing through the Players with array-loops, or getting the Player with listeners, passsing them through as arguments.

Either that, or depending on certain scenarios, you can use Remote Events and Functions.

Edit your script like this:

local w = game.Workspace
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreatePartRequest = ReplicatedStorage:WaitForChild("CreatePartRequest")

local partCFrame = script.Parent.Parent.Character.Head.CFrame + script.Parent.Parent.Character.Head.CFrame.upVector * -.3 + script.Parent.Parent.Character.Head.CFrame.lookVector * 2

CreatePartRequest:FireServer(partCFrame,script.Mesh)

And add the following script (not LocalScript!) to your ServerScriptStorage:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreatePartRequest = Instance.new("RemoteEvent")
CreatePartRequest.Name = "CreatePartRequest"
CreatePartRequest.Parent = ReplicatedStorage

local function OnCreatePartRequest(player,partCFrame,partMesh)
	
	z = Instance.new("Part",w)
        z.CFrame = partCFrame
	partMesh:Clone().Parent = z
	z.Size = Vector3.new(.15,.15,.15)
	z.Material = "Neon"
	z.BrickColor = BrickColor.new("Cool yellow")
	z.Anchored = true
	z.CanCollide = false

end
CreatePartRequest.OnServerEvent:Connect(OnCreatePartRequest)

P.s. I would suggest to store your mesh in ServerStorage, so exploiters could not modify it.

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