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

Function trouble, Not sure what the issue is this should be easy for you I hope ?

Asked by 4 years ago
Edited 4 years ago

error reads bad argument

script.Parent.Touched:Connect(function()
    game.Workspace.Change.BrickColor = BrickColor.new("Really black") 
end) 

I am trying to step on a brick and have it change the color of another brick, Im not getting anything in my output when I use this script what happens is I start the game and the part I want to change colors, changes colors as soon as I run the script instead of changing colors when I step on the brick

0
So im confused, does it error out, or change the color early mc3334 649 — 4y
0
ohhhh that makes way more since thanks !!! Army31LemaMike 0 — 4y
0
np mc3334 649 — 4y

1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
4 years ago
Edited 4 years ago

in lines 1 and 2 you define the part differently. One says the parts name is "Change" and one says the parts name is "Part". Make sure these are the same and the actual name of the part. Also in the future, be sure to include the actual error itself because it provides a lot more context.

Looking at it, the issue you described is because when the game starts, the part touches the baseplate. Just check if its a player thats touching it. Your code will look like this

game.Workspace.Part.Touched:Connect(function(obj)
    if obj.Parent:FindFirstChild("Humanoid") then
        game.Workspace.Change.BrickColor = BrickColor.new("Really Black")
    end
end)
Ad

Answer this question