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

can i change part instances texture? and size problems

Asked by 2 years ago

i was making a script whit instances but the texture of the part was different and i dont know how to change it, pls help *also, when i change the name of the part it stops working but it dosent matter rn

game.Players.PlayerAdded:Connect(function()
    local leo = game.Players:WaitForChild("leoonardo101max1")
    print("Player Found")
    local char = leo:FindFirstChild("Character")
    print("Character Found")
    local humrootpart = game.Workspace:WaitForChild("leoonardo101max1"):FindFirstChild("HumanoidRootPart")
    print("hum Found")
    while true do
        wait(0.01)
        local block = Instance.new("Part")
        block.Parent = game.Workspace
        block.Position = humrootpart.position - Vector3.new(0,2,0)
        block.CanCollide = false
        block.Anchored = true
        block.Size = Vector3.new(3,3,3)
        ---block.name = block---   <--dosent work
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

First of all, you can change a Part’s texture by changing it’s Material. To change the material, you either type Part.Material = Enum.Material.TypeAnyMaterialHere or Part.Material = “TypeAnyMaterialHere”. (NOTE: IF YOU REALLY TYPE “TypeAnyMaterial” IT WILL CAUSE SOME HUGE ERRORS. TO AVOID ERRORS, YOU CAN ONLY CHOOSE MATERIALS FROM THIS LINK ). The second way to edit the texture is to manually change each side’s Surface. What I mean by that is you will type Part.BottomSurface, .TopSurface, .LeftSurface, etc. And to actually change it, you will identify it like smooth. Here’s an example: Part.FrontSurface = “Smooth”. The third way is to use decals, textures, or SurfaceGui. They are like images on a part. You can also set it what surface of the part would the image be at. For example:

local decal = Instance.new(“Decal”)
decal.Parent = Part
decal.Texture “rbxassetid://0000000” —you can put any decalID here
decal.Face = “Front”

Second of all, the name of an object must be always a string, and a string is a word inside a quote. It’s like a message or a text. For example: Part.Name = “object”.

Third of all, if you’re trying to look for the character and print “Character found” then try this because it will be useful in the future.

if player:FindFirstChild("Character") then
       print(“Character found!”)
end

And FOURTH OF ALL, don’t use game.Players:WaitForChild(“Any username here”) if you’re trying to check if the player exists. Instead, change the first line to game.Players.PlayerAdded:Connect(function(player) and the second line to

if player ~= nil then
       print(“Player found!”)
end

But if you want to make it happen only to a specific user, the change the second line to if player.Name ~= “Any username here” then return end.

I hope this helped you because this took me almost an hour to type.

Ad

Answer this question