Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

3 comments

0

So im confused, does it error out, or change the color early

0

ohhhh that makes way more since thanks !!!

0

np

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.