Can I do Instance.new through a local script?
I tried it, in a local script. But other players can't see it. here's the script btw
local shirt = Instance.new("Part") shirt.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart shirt.Anchored = true shirt.CanCollide = false shirt.Size = Vector3.new(2.32, 2.32, 1.32) shirt.Transparency = 0.35 shirt.Name = "Anti-Skid Shirt" shirt.TopSurface = "Smooth" shirt.RightSurface = "Smooth" shirt.LeftSurface = "Smooth" shirt.BottomSurface = "Smooth" game:service'RunService'.Heartbeat:Connect(function() shirt.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame end)
I even tried to set the parent to workspace, but other player still can't see it. If there's any way to do it. Please teach me how. I accept answers!
There's a difference between using LocalScript and Script. If you want other people see the new part created, you should make in from the server. You can use service Players and use the event called PlayerAdded for when a player joins and from there use the event CharacterAdded from the player object for when the character is added and it works if you want to do something every time the character loads. There's a example to help u understand
--This needs to be done in a server script, not a localscript local Players = game:GetService("Players") --Here we get the service Players to use its events --Here we connect the event for when a player joins. The function that we connected --Receives one argument that we can call whatever we want, that argument corresponds to the player that joined Players.PlayerAdded:Connect(function(Player) --Next we do is connect the event CharacterAdded from the PlayerObject --This events fires every time the player resets or dies. --We connected it to a function that receives one argument, in this case the Character Player.CharacterAdded:Connect(function(Character) --Here we can Instance the part and do whatever we want with the character local shirt = Instance.new("Part") --Here's your code, in this case we need to replace this, since we already have the Character. --shirt.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart shirt.Parent = Character.HumanoidRootPart --shirt.Anchored = true shirt.CanCollide = false shirt.Size = Vector3.new(2.32, 2.32, 1.32) shirt.Transparency = 0.35 shirt.Name = "Anti-Skid Shirt" shirt.TopSurface = "Smooth" shirt.RightSurface = "Smooth" shirt.LeftSurface = "Smooth" shirt.BottomSurface = "Smooth" --[[game:service'RunService'.Heartbeat:Connect(function() shirt.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame end) This piece of code can be improved, you can weld the part to the HumanoidRootPart instead of changing the CFrame every frame We'll use WeldConstraint, the part that we created need to be unanchored, that's why i didn't anchor it ]] shirt.CFrame = Character.HumanoidRootPart.CFrame --We need to move the part to the HumanoidRootPart CFrame so it stays in that place local WeldConstraint = Instance.new("WeldConstraint", shirt) WeldConstraint.Part0 = shirt WeldConstraint.Part1 = Character.HumanoidRootPart end) end)