#feedback

31 messages · Page 1 of 1 (latest)

rocky glacier
#

I'm trying to improve on the script, I'm watching some videos and I tried to make this script when played, change the color of the part to red, give me tips and tell me if I'm progressing, (3 days on roblox studio) please

atomic lodge
#

Idk wtf I'm reading.

rocky glacier
atomic lodge
#

Explain line by line, here, what you want to accomplish.

#

So both you and me understand be underlying logic.

rocky glacier
#

I want to script a part, that when you tap on it, it changes color to red

atomic lodge
#

Explain line by line.

#

In your script.

#

You're doing it for yourself, not for me.

#

I see the issues and I see what you want to accomplish. But I don't know if you get what you're doing.

#

Gotta develop a linear logic there.

rocky glacier
#

I'm using google translator, I don't know how to speak English properly

#

but

#

first line makes the touched event connect to the hit function

opal path
#

well thats alot of lines

rocky glacier
#

second makes "legal" = script.parent

rocky glacier
opal path
#

and what does line 3 do

rocky glacier
#

bruh

#

I think I found the mistake

opal path
#

line 3 is the mistake

#

leftSide = rightSide
something = 5

#

rightSide gets evaluted into a literal

#

also Legal is always going to be a truthy value

#

cause script.Parent always exists

rocky glacier
#

I think I got it

torpid sage
#

i dont know if this is needed anymore but here is a informative explanation shrugs

#

"hit" would be the thing touching the part (like a player or another part)

i am assuming "Legal" is the part you want to trigger the touch function, so instead do:

Legal.Touched:Connect(function(hit)
    print("touched by", hit)
end)

once again "hit" will be whatever/whoever touched the part, and (assuming) "Legal" is the touch part

now you want to check if whatever/whoever is touching the part is a player (once again assuming you only want players to trigger this function, and not whatever touched it)

local Legal = script.Parent

Legal.Touched:Connect(function(hit)

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    
    if player then
        print("A player has touched the part!")
        
    end
end)

a print will show in the output if the thing hitting the "Legal" part is a player, otherwise if not a player nothing will happen

now if you want to change the color of the part "Legal" then I suggest taking a look at the properties tab, you can see there is an "appearance" section where you can change the color, material, and more.

basically you will want to navigate there via script, to do that you will want to find the part, then the "color" property. there are two options; "brick color" and "color", brick color will have you select from roblox's pallet while "color" is a wheel and you'll need to provide a RGB, HSV, or Hex color code.

example: turning the block red using brick color

local Legal = script.Parent

Legal.Touched:Connect(function(hit)

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    
    if player then
        print("A player has touched the part!")
        
        Legal.BrickColor = BrickColor.Red()
        
    end
    
end)

using RGB

Legal.Color = Color3.fromRGB(255, 0, 0)

using HSV

Legal.Color = Color3.fromHSV(0, 1, 1)

using Hex

Legal.Color = Color3.fromHex("#ff0000")

probably best to use RGB, personally...

rocky glacier
#

oh