Working on a solo project

I got bored recently and decided to start a little project. I can’t really script, so I figured that this will (hopefully) help me script better. But right now I ran into an issue that I couldn’t find a solution for.

Basically, I planned it so that you merge the colors, and you need to fill an index with these colors. I plan on making special effects and stuff, but this is all i have right now.

Now time for the problem - Whenever you mix the colors, I scripted it so the main color changes its name. Although I’ve thought on changing this, it seemed to be the easiest way. So when red and green merge, it gives you yellow. Simple enough, but when yellow and blue merge, the color is supposed goes back to green. Instead, it goes back to purple

The script is below (I organized it)

— BASE COLOR VARIABLES —
local BluePart = workspace.BluePart
local RedPart = workspace.RedPart
local GreenPart = workspace.GreenPart

— MERGED COLOR VARIABLES —
local YellowPart = workspace.WaitForChild:(‘YellowPart’)) – This is where the error is

— PURPLE —
BluePart.Touched:Connect(function(touched)
if touched == RedPart and BluePart.Name == “BluePart” then
RedPart:Destroy()
BluePart.Attachment.Sparkles.Enabled = true
wait(.2)
BluePart.Attachment.Sparkles.Enabled = false
BluePart.Size = BluePart.Size + RedPart.Size
BluePart.BrickColor = BrickColor.new(“Eggplant”)
BluePart.Name = “PurplePart”
end
end)

— TURQUOISE —
BluePart.Touched:Connect(function(touched)
if touched == GreenPart and BluePart.Name == “BluePart” then
GreenPart:Destroy()
BluePart.Attachment.Sparkles.Enabled = true
wait(.2)
BluePart.Attachment.Sparkles.Enabled = false
BluePart.Size = BluePart.Size + GreenPart.Size
BluePart.BrickColor = BrickColor.new(“Turquoise”)
BluePart.Name = “TurquoisePart”
end
end)

And then another script for the red part merging with other parts

— BASE COLOR VARIABLES —
local BluePart = workspace.BluePart
local RedPart = workspace.RedPart
local GreenPart = workspace.GreenPart

— YELLOW —
RedPart.Touched:Connect(function(touched)
if touched == GreenPart and RedPart.Name == “RedPart” then
GreenPart:Destroy()
RedPart.Attachment.Sparkles.Enabled = true
wait(.2)
RedPart.Attachment.Sparkles.Enabled = false
RedPart.Size = RedPart.Size + GreenPart.Size
RedPart.BrickColor = BrickColor.new(“New Yeller”)
RedPart.Name = “YellowPart”
end
end)

The error says: Expected identifier when parsing method name, got ‘(’. You can go into studio if you want too and test this out. I put these scripts into Server Script Service. Any help is appreciated. Thank You :pray:!

image

when using waitforchild this is the correct syntax

local YellowPart = workspace:WaitForChild("YellowPart")

you first have the object that you want to find the child in. in this case its workspace

then you do the colon " : "

then you write WaitForChild

then in brackets and quotes you write the name of the child

also, try to use #help-and-feedback:scripting-support as the tag for your next post regarding scripting. other than that, enjoy coding!

didnt know it was an easy fix ty!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.