script.Parent.Touched:connect(function(hit)
if hit.Name ~= "Sausage" then
local part = workspace.Sausage
print("Cooking")
part.Color = Color3.fromRGB(124, 65, 64)
print("Done")
else
print("Not sausage")
end
end)
when i made it a server script any time i touched the part then the colour would change even tho i want the part named sausage to change colour when ever it touches the part and when i made it a local script OFC it would not work.
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Sausage" then -- if name of 'hit' part is "Sausage" (replaced '~=' with '=='
local part = workspace.Sausage
print("Cooking")
part.Color = Color3.fromRGB(124, 65, 64)
print("Done")
else -- if not
print("Not sausage")
end
end)
You were checking if the hit part was not a part named ‘Sausage’ (symbols: ~=), which is likely why you are facing this issue.
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Sausage" then
local part = workspace.Sausage
print("Cooking")
part.Color = Color3.fromRGB(125,65,64)
print("Done")
else
print("Not sausage")
end
end)
Im pretty sure you didnt mean to say ~= and meant ==, ~= means not, == means is basically. If you wanted to do multiple sausages, you could also remove the
local part = workspace.Sausage
and just do
hit.Color = Color3.fromRGB(124, 65, 64)
That would make it so whenever any sausage hits the cooker (im assuming its a cooking device) it would cook instead of only 1 being able to cook. Best of luck!