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

My dice wont turn green when it is touched on a brick. Whats wrong?

Asked by 5 years ago

So im making a really basic script (hard for me bc im new) but it doesnt seem to turn the di green when It touches the brick heres the script

local Dice1 = game.Workspace.Dice1
local Dice2 = game.Workspace.Dice2

script.Parent.Touched:Connect(function(hit)

    if hit.parent:FindFirstChild("Dice1")


    then
Dice1.BrickColor = BrickColor.new('Sage green')


    end


end)
0
What is touching the brick? The other dice? the player? Looks like something's wrong with Line6 since Dice1 is in the workspace and you're looking for the dice in whatever just hit the brick. royaltoe 5144 — 5y

1 answer

Log in to vote
0
Answered by
RSASDSA 72
5 years ago
Edited 5 years ago
hit.parent:FindFirstChild("Dice1") 

is incorrect. You should be using Parent. also, if you only want dice1 to become green after being touched, you should do

hit == Dice1

as otherwise it will affect every part that is a direct child of the workspace, because hit.Parent in this context is the Workspace, and the Workspace will always have the Dice1 descendant

Ad

Answer this question